RESOLVED FIXED 202608
DOMCacheStorage should not prevent pages from entering the back/forward cache
https://bugs.webkit.org/show_bug.cgi?id=202608
Summary DOMCacheStorage should not prevent pages from entering the back/forward cache
Chris Dumez
Reported 2019-10-04 15:29:24 PDT
DOMCacheStorage should not prevent pages from entering the back/forward cache.
Attachments
Patch (15.40 KB, patch)
2019-10-04 15:58 PDT, Chris Dumez
no flags
Patch (17.63 KB, patch)
2019-10-07 13:46 PDT, Chris Dumez
no flags
Patch (17.66 KB, patch)
2019-10-09 12:24 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2019-10-04 15:58:06 PDT
Radar WebKit Bug Importer
Comment 2 2019-10-07 08:14:30 PDT
Chris Dumez
Comment 3 2019-10-07 13:46:09 PDT
Chris Dumez
Comment 4 2019-10-08 10:35:24 PDT
Comment on attachment 380355 [details] Patch Ready for review.
Chris Dumez
Comment 5 2019-10-09 08:15:48 PDT
ping review?
youenn fablet
Comment 6 2019-10-09 08:25:10 PDT
Comment on attachment 380355 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=380355&action=review > Source/WebCore/Modules/cache/DOMCacheStorage.cpp:223 > + }); Shouldn’t we create the cache at the time we execute the enquêtes task?
Chris Dumez
Comment 7 2019-10-09 08:49:52 PDT
Comment on attachment 380355 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=380355&action=review >> Source/WebCore/Modules/cache/DOMCacheStorage.cpp:223 >> + }); > > Shouldn’t we create the cache at the time we execute the enquêtes task? enquêtes huh? :) How French. I actually wasn't sure about the right time to append the cache to m_caches (assuming this is what you meant). I could do it in the lambda, or outside like I ended up doing. It looks to me like the current code is unsafe when there are several parallel requests to doOpen() for the same name. You may end up creating the 2 DOMCache objects for the same name and have 2 caches for the same name in m_caches. Is that right or am I missing something? The reason I appended the cache to m_caches synchronously rather than in the enqueued task was to not make this *race* worse. Also, while I see a good reason to resolve the promise in an async task, I did not see a need to delay the creation of the cache or adding it to m_caches.
youenn fablet
Comment 8 2019-10-09 12:09:32 PDT
(In reply to Chris Dumez from comment #7) > Comment on attachment 380355 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=380355&action=review > > >> Source/WebCore/Modules/cache/DOMCacheStorage.cpp:223 > >> + }); > > > > Shouldn’t we create the cache at the time we execute the enquêtes task? > > enquêtes huh? :) How French. I did the enquete and the culprit....my phone autocompletion enqueued -> enquêtes! On the other side, enquete -> enquire... > I actually wasn't sure about the right time to append the cache to m_caches > (assuming this is what you meant). I could do it in the lambda, or outside > like I ended up doing. > It looks to me like the current code is unsafe when there are several > parallel requests to doOpen() for the same name. You may end up creating the > 2 DOMCache objects for the same name and have 2 caches for the same name in > m_caches. Is that right or am I missing something? > The reason I appended the cache to m_caches synchronously rather than in the > enqueued task was to not make this *race* worse. Also, while I see a good > reason to resolve the promise in an async task, I did not see a need to > delay the creation of the cache or adding it to m_caches. Well, we could be suspended and DOMCache is an ActiveDOMObject. Also, creating an object while we might never use it is not great. I guess the alternative would be to not make DOMCache an ActiveDOMObject and instead have the CacheStorageConnection be an ActiveDOMObject (hence being owned by the Document). The CacheStorageConnection would then buffer all the callbacks if needed. I guess we can do that if reducing the number of ActiveDOMObjects is motivating enough. As of the race, if you call open with the same name, you will end up with two JSDOMCache pointing to the same request/response set. I believe this is as per spec and the creation of the cache object is synchronous with the promise resolution. We are doing some caching in DOMCacheStorage for skipping sending some IPC to network process. It should not (at least in theory) change the observable JS behaviour, except for getting faster promise resolutions.
Chris Dumez
Comment 9 2019-10-09 12:20:15 PDT
(In reply to youenn fablet from comment #8) > (In reply to Chris Dumez from comment #7) > > Comment on attachment 380355 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=380355&action=review > > > > >> Source/WebCore/Modules/cache/DOMCacheStorage.cpp:223 > > >> + }); > > > > > > Shouldn’t we create the cache at the time we execute the enquêtes task? > > > > enquêtes huh? :) How French. > > I did the enquete and the culprit....my phone autocompletion > enqueued -> enquêtes! > > On the other side, enquete -> enquire... > > > I actually wasn't sure about the right time to append the cache to m_caches > > (assuming this is what you meant). I could do it in the lambda, or outside > > like I ended up doing. > > It looks to me like the current code is unsafe when there are several > > parallel requests to doOpen() for the same name. You may end up creating the > > 2 DOMCache objects for the same name and have 2 caches for the same name in > > m_caches. Is that right or am I missing something? > > The reason I appended the cache to m_caches synchronously rather than in the > > enqueued task was to not make this *race* worse. Also, while I see a good > > reason to resolve the promise in an async task, I did not see a need to > > delay the creation of the cache or adding it to m_caches. > > Well, we could be suspended and DOMCache is an ActiveDOMObject. I do not think this is an issue. AFAIK, it is perfectly fine to create ActiveDOMObjects while suspended, this is exactly why you must call suspendIfNeeded() on an ActiveDOMObject right after constructing. What's not allowed is constructing new ActiveDOMObject in the implementation of suspend() / resume(). > Also, creating an object while we might never use it is not great. Fair point. > I guess the alternative would be to not make DOMCache an ActiveDOMObject and > instead have the CacheStorageConnection be an ActiveDOMObject (hence being > owned by the Document). The CacheStorageConnection would then buffer all the > callbacks if needed. > I guess we can do that if reducing the number of ActiveDOMObjects is > motivating enough. > > As of the race, if you call open with the same name, you will end up with > two JSDOMCache pointing to the same request/response set. > I believe this is as per spec and the creation of the cache object is > synchronous with the promise resolution. Ok, as long as you're not concerned about the potential race, then I'll move the cache creation.
Chris Dumez
Comment 10 2019-10-09 12:24:08 PDT
WebKit Commit Bot
Comment 11 2019-10-10 07:24:15 PDT
Comment on attachment 380554 [details] Patch Clearing flags on attachment: 380554 Committed r250965: <https://trac.webkit.org/changeset/250965>
WebKit Commit Bot
Comment 12 2019-10-10 07:24:16 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.