WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
202074
Stop refing UniqueIDBDatabaseTransaction in callbacks
https://bugs.webkit.org/show_bug.cgi?id=202074
Summary
Stop refing UniqueIDBDatabaseTransaction in callbacks
Sihui Liu
Reported
2019-09-21 00:17:09 PDT
After quota check is introduced to IDB, the callback that takes the ref of UniqueIDBDatabaseTransaction will be passed to StorageQuotaManager. Previously the callback was only passed to UniqueIDBDatabase and UniqueIDBDatabase would make sure they were called before UniqueIDBDatabase was destroyed. Now UniqueIDBDatabaseTransaction may live longer than UniqueIDBDatabase.
Attachments
Patch
(28.88 KB, patch)
2019-09-21 00:19 PDT
,
Sihui Liu
no flags
Details
Formatted Diff
Diff
Patch
(38.62 KB, patch)
2019-09-23 09:12 PDT
,
Sihui Liu
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Sihui Liu
Comment 1
2019-09-21 00:19:54 PDT
Created
attachment 379313
[details]
Patch
youenn fablet
Comment 2
2019-09-22 23:02:11 PDT
Comment on
attachment 379313
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=379313&action=review
> Source/WebCore/ChangeLog:10 > + UniqueIDBDatabase.
Your patch seems to move away from refing UniqueIDBDatabaseTransaction and instead use WeakPtr. Would it be possible to make UniqueIDBDatabaseTransaction no longer be RefCounted?
> Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp:1229 > + requestSpace(taskSize, "putOrAdd", [this, taskSize, transaction = makeWeakPtr(transaction), requestData, keyData, value, callback = WTFMove(callback), overwriteMode](auto error) mutable {
With your changes, it seems requestSpace could take a UniqueIDBDatabaseTransaction&, create the makeWeakPtr itself and return UnknownError. This would put the transaction check in only one place. This would also apply well to waitForRequestSpaceCompletion.
> Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:82 > + database->abortTransaction(*this, UniqueIDBDatabase::WaitForPendingTasks::Yes, [this, weakThis = makeWeakPtr(*this)](const IDBError& error) {
Could use auto& for error
Sihui Liu
Comment 3
2019-09-23 08:45:01 PDT
(In reply to youenn fablet from
comment #2
)
> Comment on
attachment 379313
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=379313&action=review
> > > Source/WebCore/ChangeLog:10 > > + UniqueIDBDatabase. > > Your patch seems to move away from refing UniqueIDBDatabaseTransaction and > instead use WeakPtr. > Would it be possible to make UniqueIDBDatabaseTransaction no longer be > RefCounted? >
UniqueIDBDatabaseTransaction can be kept alive by UniqueIDBDatabase and be destroyed when it's finished. We just need to make sure last ref of UniqueIDBDatabaseTransaction is properly released when UniqueIDBDatabase is closed.
> > Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp:1229 > > + requestSpace(taskSize, "putOrAdd", [this, taskSize, transaction = makeWeakPtr(transaction), requestData, keyData, value, callback = WTFMove(callback), overwriteMode](auto error) mutable { > > With your changes, it seems requestSpace could take a > UniqueIDBDatabaseTransaction&, create the makeWeakPtr itself and return > UnknownError. > This would put the transaction check in only one place. > This would also apply well to waitForRequestSpaceCompletion. >
Okay. Will make this change.
> > Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:82 > > + database->abortTransaction(*this, UniqueIDBDatabase::WaitForPendingTasks::Yes, [this, weakThis = makeWeakPtr(*this)](const IDBError& error) { > > Could use auto& for error
Sure.
Sihui Liu
Comment 4
2019-09-23 09:12:38 PDT
Created
attachment 379373
[details]
Patch
youenn fablet
Comment 5
2019-09-24 05:42:00 PDT
Comment on
attachment 379373
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=379373&action=review
> Source/WebCore/ChangeLog:9 > + passed to StorageQuotaManager. This can make UniqueIDBDatabaseTransaction live longer than UniqueIDBDatabase.
LGTM. As long as UniqueIDBDatabaseTransaction is RefCounted, we have no real way of guaranteeing that UniqueIDBDatabaseTransaction will never live longer than UniqueIDBDatabase. Ideally, we should try to make UniqueIDBDatabaseTransaction no longer RefCounted. Instead, UniqueIDBDatabase will have unique_ptr<UniqueIDBDatabaseTransaction> and other users of transaction will have WeakPtr<UniqueIDBDatabaseTransaction>.
Sihui Liu
Comment 6
2019-09-24 13:27:08 PDT
(In reply to youenn fablet from
comment #5
)
> Comment on
attachment 379373
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=379373&action=review
> > > Source/WebCore/ChangeLog:9 > > + passed to StorageQuotaManager. This can make UniqueIDBDatabaseTransaction live longer than UniqueIDBDatabase. > > LGTM. > As long as UniqueIDBDatabaseTransaction is RefCounted, we have no real way > of guaranteeing that UniqueIDBDatabaseTransaction will never live longer > than UniqueIDBDatabase. > Ideally, we should try to make UniqueIDBDatabaseTransaction no longer > RefCounted. > Instead, UniqueIDBDatabase will have > unique_ptr<UniqueIDBDatabaseTransaction> and other users of transaction will > have WeakPtr<UniqueIDBDatabaseTransaction>.
I see. I will make a follow-up patch if that does not break things.
WebKit Commit Bot
Comment 7
2019-09-24 14:11:41 PDT
Comment on
attachment 379373
[details]
Patch Clearing flags on attachment: 379373 Committed
r250317
: <
https://trac.webkit.org/changeset/250317
>
WebKit Commit Bot
Comment 8
2019-09-24 14:11:42 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 9
2019-09-24 14:12:20 PDT
<
rdar://problem/55676811
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug