[Webkit-unassigned] [Bug 252544] If a Home Screen Web App is backgrounded and tries to focus() a ServiceWorkerWindowClient in a notificationclick handler, the focus() promise rejects

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Mar 7 18:48:53 PST 2023


https://bugs.webkit.org/show_bug.cgi?id=252544

--- Comment #9 from Brady Eidson <beidson at apple.com> ---
Setting aside postMessage not working, focus() is also not working.

Here's what happens:
1 - The app launches and starts a page load for the root URL of the web app - https://taoshu.in/web/push-demo/ in this case. This happens in web content process A.
2 - That load has a ScriptExecutionContextIdentifier associated with it. Importantly, this identifier is what the eventual Document *will* have, but that document does not exist yet.
3 - The networking process is asked to load https://taoshu.in/web/push-demo/. As part of that resource load it is given the context identifier. So the networking process remembers "There is a window client for this URL with this identifier.
4 - The service worker is fired up in web content process B to handle the notification click. This happens right away, before the main page document has really started loading.
5 - In the notification click handler, the SW does a matchAll on clients looking for window clients
6 - That matchAll goes to the networking process, which knows about the eventual client. So it returns that UUID
7 - Back in web content B, the SW has the results of the matchAll and tries to call focus() on the window client.
8 - That focus call is routed to the networking process based on UUID, which knows that the document *should be* in Web Content process A. So it forwards the call there
9 - In Web Content process A, the focus() attempt tries to look up the Document for that UUID and fails. Remember from step 2, the eventual Document that will be created will have that UUID, but that Document doesn't exist yet.
10 - The failure is routed to Networking, which then routes to Web Content B, and then rejects the focus() promise. Whoops!
11 - Almost immediately after that rejection, data *does* come in for the main page document, therefore *actually creating the Document object in Web Content A*, ensuring that a future focus() call would actually work.


Your experimenting suggests removing the focus call still causes failure. I'd need to see the exact code you changed it to to take a look.

(Note: Please do *not* change the live site I'm debugging with now! Make a second copy and mention it if that is something you'd like to do)

Whatever you changed it to may be affected by a very similar issue, or something different, but: the focus() issue is definitely real.

(FWIW, I still have a private test with postMessage working just fine, but it's simply different than yours)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230308/3a41d413/attachment.htm>


More information about the webkit-unassigned mailing list