Bug 256280

Summary: Webkit PWA in Bad State After Opening in-PWA Webkit Tab
Product: WebKit Reporter: goehdavi
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Blocker CC: webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: iPhone / iPad   
OS: iOS 16   

Description goehdavi 2023-05-03 16:28:17 PDT
When we use window.open(url, "_blank") to bring up a new Safari tab/window with our PWA we see that the document.visibilityState is not updated and then returning to the PWA from the webview/tag results in fetch calls failing with Unhandled Promise Rejection: AbortError: Fetch is aborted. All fetch calls fail until the PWA is refreshed or closed and then opened again.
Comment 1 goehdavi 2023-05-04 02:22:18 PDT
Upon further investigation it seems document.visibilityState is updated and that clicking Done from the Safari window does not cause the issue. It is only caused when handoff javascript executes in the other window (calls to window.opener.postMessage). We are unsure why this breaks all fetch calls.
Comment 2 Radar WebKit Bug Importer 2023-05-04 02:37:07 PDT
<rdar://problem/108884055>
Comment 3 goehdavi 2023-05-05 20:11:56 PDT
It appears the issue is related to the service worker becoming unresponsive. Our service worker has no fetch handler but all network calls failed when a redirect was performed in the new safari tab. Resetting the service worker (unregistering the service worker and then refreshing the page) resolved the issue.
Comment 4 youenn fablet 2023-05-09 07:38:39 PDT
Pull request: https://github.com/WebKit/WebKit/pull/13639
Comment 5 EWS 2023-05-10 08:22:24 PDT
Committed 263901@main (7a4f94728cde): <https://commits.webkit.org/263901@main>

Reviewed commits have been landed. Closing PR #13639 and removing active labels.
Comment 6 EWS 2023-05-15 09:47:42 PDT
Committed 264076@main (f1665400b299): <https://commits.webkit.org/264076@main>

Reviewed commits have been landed. Closing PR #13740 and removing active labels.