Conversation
|
Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs). |
| "version_added": false | ||
| "version_added": "14", | ||
| "partial_implementation": true, | ||
| "notes": "Works only with App Bound Domains (up to 10 domains) and for apps with the Web Browser entitlement." |
There was a problem hiding this comment.
This note needs to explain what "works" means. I'd expect to see something like…
The
ServiceWorkerAPI is not exposed unless the webview is configured for app bound domains…
Or depending on the particulars, this data might somewhere else, e.g.,:
The
navigator.serviceWorker.register()method throws unless the webview is configured for app bound domains…
There was a problem hiding this comment.
Unfortunately, I don't know the particulars for it.
There was a problem hiding this comment.
@NiklasMerz Do you know anything about this? Something worth recording in BCD?
If not, we'll close this PR.
There was a problem hiding this comment.
I haven't used ServiceWorkers in WKWebView myself but this limitation seems to be correct. I found multiple sources and this WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=206741. That also states it's supported only for HTTP and HTTPs whereas some WebView developers (including Cordova, Capacitor) use custom schemes.
Supporting ServiceWorker only with AppBound domains and HTTP(S) is a serious limitation worth recording in BCD I think.
There was a problem hiding this comment.
Thank you, @NiklasMerz! One follow up: do you have any idea how the limitation manifests? The linked bug doesn't explain what lack of support means exactly (e.g., does "serviceWorker" in navigator return false? Is ServiceWorker exposed regardless? Or is there some kind of exception on registration?).
There was a problem hiding this comment.
Also, where do I set the domains for "App-Bound Domains"?
There was a problem hiding this comment.
You need to set the domains in Info.plist (there is an UI for that not sure what it's called from memory) and then webViewConfiguration.limitsNavigationsToAppBoundDomains = YES;
https://webkit.org/blog/10882/app-bound-domains/
(I tried AppBoundDomains many years ago but it didn't work for my use case so I'm not sure how it works today).
There was a problem hiding this comment.
I got Florians PR to work and the next version of CanIWebView 1.1.0 will have collector.openwebdocs.org as an AppBoundDomain. You can enable limitsNavigationsToAppBoundDomains on the config tab.
The update is in review for the App Store so keep an eye out for Apple to approve and publish it.
In my local build the BCD collector tests somehow get stuck at "Running tests for Service Worker" when I enable that setting. Looks like they still don't work and I get this in the logs:
[Log] Running tests for Service Worker... (harness.js, line 59)
[Error] Unhandled Promise Rejection: TypeError: Job rejected for non app-bound domain
[Error] WebSocket connection to 'wss://echo.websocket.org/' failed: Ungültige Antwort vom Server. (x5)
The Service Worker test might need to be adjusted.
There was a problem hiding this comment.
hmm, at least I can see an exposure change when running the collector in the app. Without AppBoundDomain https://collector.openwebdocs.org/tests/api/ServiceWorker?exposure=Window tests are false, and they are true when AppBoundDomain is enabled.
So, that I think answers Daniel's questions above.
Not sure what is going on when running the full collector tests. Is there a way to get to the error console myself in the app?
There was a problem hiding this comment.
AFAIK you can only really go into the console and debugger if you build and run the app yourself. Production builds from the App Store are not debuggable.
If you have a mac you can clone the repo, open it in Xcode and you should be able to build and run the app using the free developer account. (I can invite you to a paid account as well if needed). Apple signing stuff is always a bit finicky.
Summary
This PR adds webview on iOS support with a not specifying the limitations
Test results and supporting details
stackoverflow.com/a/64155509/3255152
webkit.org/blog/10882/app-bound-domains
Related issues
fixes #27470