WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
182444
ServiceWorker registration should store any script fetched through importScripts
https://bugs.webkit.org/show_bug.cgi?id=182444
Summary
ServiceWorker registration should store any script fetched through importScripts
youenn fablet
Reported
2018-02-02 11:54:10 PST
We should be implementing
https://w3c.github.io/ServiceWorker/#importscripts
basically.
Attachments
WIP
(43.34 KB, patch)
2018-05-23 10:27 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(47.35 KB, patch)
2018-06-01 09:18 PDT
,
youenn fablet
ews-watchlist
: commit-queue-
Details
Formatted Diff
Diff
Archive of layout-test-results from ews107 for mac-sierra-wk2
(2.74 MB, application/zip)
2018-06-01 10:31 PDT
,
EWS Watchlist
no flags
Details
Patch
(51.90 KB, patch)
2018-06-01 10:40 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(63.16 KB, patch)
2018-06-04 18:21 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(63.14 KB, patch)
2018-06-04 20:52 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(63.14 KB, patch)
2018-06-05 07:50 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2018-02-02 11:54:56 PST
<
rdar://problem/37164835
>
Jim Pick
Comment 2
2018-05-19 13:14:19 PDT
I've been having problems with service worker generated using Google's Workbox tool not working offline after a period of time (on iOS). I believe it's because Workbox splits its functionality into several small .js files which loaded by importScripts. The offline functionality seems to work for while, and then it doesn't. I believe it's because the workbox-v3.2.0/*.js requests in the cache are getting evicted, and they aren't stored otherwise. When if fails, I get "Safari cannot open the page because your iPhone is not connected to the Internet." The app is simple and completely open source:
https://dat-shopping-list.glitch.me/
The code to generate the service worker is here:
https://glitch.com/edit/#!/dat-shopping-list?path=server/makeServiceWorker.js:1:0
I've tried adding a cache-control http header to the /workbox-* files of 'public,max-age=31536000,immutable' but it seems the scripts still get evicted after a short period of time. The http headers on google's CDN for workbox only has a one hour expiry.
youenn fablet
Comment 3
2018-05-23 10:27:52 PDT
Created
attachment 341102
[details]
WIP
youenn fablet
Comment 4
2018-06-01 09:18:33 PDT
Created
attachment 341764
[details]
Patch
EWS Watchlist
Comment 5
2018-06-01 10:31:00 PDT
Comment on
attachment 341764
[details]
Patch
Attachment 341764
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.webkit.org/results/7926412
New failing tests: imported/w3c/web-platform-tests/service-workers/service-worker/registration-mime-types.https.html
EWS Watchlist
Comment 6
2018-06-01 10:31:01 PDT
Created
attachment 341770
[details]
Archive of layout-test-results from ews107 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
youenn fablet
Comment 7
2018-06-01 10:40:35 PDT
Created
attachment 341771
[details]
Patch
Chris Dumez
Comment 8
2018-06-04 09:03:54 PDT
Comment on
attachment 341771
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=341771&action=review
> Source/WebCore/workers/WorkerScriptLoader.cpp:57 > + bool isServiceWorkerGlobalScope = workerGlobalScope.isServiceWorkerGlobalScope();
is<ServiceWorkerGlobalScope>(workerGlobalScope) is the preferred way.
> Source/WebCore/workers/WorkerScriptLoader.cpp:235 > + return !m_cachedScript.isNull() ? m_cachedScript : m_script.toString();
I am not sure how useful m_cachedScript is here. I think we could reuse m_script and merely append() the script to it, no? Looking at the implementation of StringBuilder, a single append(String) then toString() should be pretty efficient.
> Source/WebCore/workers/service/ServiceWorkerContextData.cpp:35 > + HashMap<URL, ImportedScript> map;
Could you please add a CrossThreadCopierBase specialization for HashMap to CrossThreadCopier.h? (we already have one for Vector and HashSet). Then you can use crossThreadCopy(scriptResourceMap) here.
> Source/WebCore/workers/service/ServiceWorkerContextData.h:46 > + String responseURL;
Why isn't this stored as a URL type?
> Source/WebCore/workers/service/ServiceWorkerContextData.h:145 > + // FIXME: Add a templated version of HashMap encode/decode
What's wrong with the one in ArgumentCoders.h? We already encode / decode HashMap, there's got to be a better way than duplicating this code here.
> Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp:133 > +std::optional<ServiceWorkerContextData::ImportedScript> ServiceWorkerGlobalScope::scriptResource(const URL& url) const
Cannot we return a ServiceWorkerContextData::ImportedScript* to avoid copying?
> Source/WebCore/workers/service/server/RegistrationDatabase.cpp:50 > +static const int schemaVersion = 2;
do we need to rename all the v1 methods below to v2? also, there is an ASSERT_NOT_REACHED() below when this is not true: if (currentSchema == v1RecordsTableSchema() || currentSchema == v1RecordsTableSchemaAlternate()) Wouldn't people with an existing database hit it?
> Source/WebCore/workers/service/server/RegistrationDatabase.cpp:355 > + HashMap<URL, ServiceWorkerContextData::ImportedScript> scriptResourceMap;
Where is this populated?
> Source/WebCore/workers/service/server/RegistrationDatabase.cpp:360 > +
extra blank line?
Chris Dumez
Comment 9
2018-06-04 09:45:57 PDT
Comment on
attachment 341771
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=341771&action=review
>> Source/WebCore/workers/service/server/RegistrationDatabase.cpp:50 >> +static const int schemaVersion = 2; > > do we need to rename all the v1 methods below to v2? > > also, there is an ASSERT_NOT_REACHED() below when this is not true: > if (currentSchema == v1RecordsTableSchema() || currentSchema == v1RecordsTableSchemaAlternate()) > > Wouldn't people with an existing database hit it?
I would be good if Brady could take a look at the changes to this file.
youenn fablet
Comment 10
2018-06-04 18:21:58 PDT
Created
attachment 341942
[details]
Patch
youenn fablet
Comment 11
2018-06-04 20:52:44 PDT
Created
attachment 341952
[details]
Patch
youenn fablet
Comment 12
2018-06-05 07:50:26 PDT
Created
attachment 341966
[details]
Patch
WebKit Commit Bot
Comment 13
2018-06-05 11:50:48 PDT
Comment on
attachment 341966
[details]
Patch Clearing flags on attachment: 341966 Committed
r232516
: <
https://trac.webkit.org/changeset/232516
>
WebKit Commit Bot
Comment 14
2018-06-05 11:50:49 PDT
All reviewed patches have been landed. Closing bug.
bertrand
Comment 15
2019-03-19 04:02:02 PDT
Sorry to respond to a close ticket but I can't find a way to know when this fix will be integrated into official (non- technical preview) version of Safari iOS. More generally, is there a table mapping official Safari release and WebKit preview releases ?
youenn fablet
Comment 16
2019-03-19 18:53:22 PDT
(In reply to bertrand from
comment #15
)
> Sorry to respond to a close ticket but I can't find a way to know when this > fix will be integrated into official (non- technical preview) version of > Safari iOS. More generally, is there a table mapping official Safari release > and WebKit preview releases ?
Hi Bertrand, I believe Mojave or iOS12 should have the fix.
bertrand
Comment 17
2019-03-20 00:41:54 PDT
Thanks Youenn. I'll try Workbox again with ios 12.1.4 safari then. Thus, I assume there is no way to know for sure when a Webkit fix is embedded into an official release... That's a problem.
Ryosuke Niwa
Comment 18
2019-03-22 20:14:27 PDT
(In reply to bertrand from
comment #17
)
> Thanks Youenn. I'll try Workbox again with ios 12.1.4 safari then. > > Thus, I assume there is no way to know for sure when a Webkit fix is > embedded into an official release... That's a problem.
It's because after we branch, we merge many fixes. So we can't say we included revision X of WebKit in version Y of Safari. Here's some trick. If you open Safari's version number, it'd say something like 14607.1.~. Strip "14" or whatever leading two digits, and then look for that branch in:
https://trac.webkit.org/browser/webkit/branches
e.g.
https://trac.webkit.org/browser/webkit/branches/safari-607-branch
in this case. Some tag/branch created off of this branch is probably what Safari includes.
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