-
Notifications
You must be signed in to change notification settings - Fork 116
fix: [SDK-4336] guard IndexedDB Options writes from iOS Safari PWA wedge #1468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sherwinski
wants to merge
10
commits into
main
Choose a base branch
from
sherwin/sdk-4336
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+256
−10
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ff4b4db
chore(preview): [SDK-4336] add iOS PWA repro sandbox (revert before m…
sherwinski 5007edf
fix: [SDK-4336] fail-fast Options writes to avoid iOS PWA init hang
sherwinski 1b826e7
perf: [SDK-4336] short-circuit Options writes after first wedge
sherwinski 5ad8fa3
fix: [SDK-4336] extend timeout/breaker to all readwrite ops
sherwinski 98f86a8
Revert "fix: [SDK-4336] extend timeout/breaker to all readwrite ops"
sherwinski 58dcde6
chore: [SDK-4336] trim warning strings and adjust size-limit budget
sherwinski b8a0dff
refactor: [SDK-4336] consolidate Options-write guard and trim noise
sherwinski 69158f2
docs: [SDK-4336] link WebKit bug 315804 in Options-write guard comment
sherwinski 5c4d4dd
fix: [SDK-4336] tighten timer scope and defer appId commit on wedge
sherwinski 7716b57
refactor: [SDK-4336] address review feedback and add unit tests
sherwinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>SDK-4336 Repro: Page A</title> | ||
| <link rel="shortcut icon" href="#" /> | ||
| <link rel="manifest" href="manifest.json" /> | ||
| <meta name="apple-mobile-web-app-capable" content="yes" /> | ||
| <meta name="apple-mobile-web-app-status-bar-style" content="default" /> | ||
| <meta name="apple-mobile-web-app-title" content="SDK4336" /> | ||
|
|
||
| <script src="sdks/web/v16/Dev-OneSignalSDK.page.js" defer></script> | ||
|
|
||
| <script> | ||
| console.log('!!!! [SDK-4336 PAGE A] OneSignal initialize'); | ||
|
|
||
| function getUrlQueryParam(name) { | ||
| const urlParams = new URLSearchParams(window.location.search); | ||
| return urlParams.get(name); | ||
| } | ||
|
|
||
| // Resolve the app_id robustly. The in-page links to Page B/Page A don't | ||
| // carry the query string, and on an iOS standalone (home-screen) PWA the | ||
| // localStorage fallback isn't reliable across A->B->A navigations because | ||
| // storage is partitioned per context. Without a hardcoded fallback, the | ||
| // B->A load calls OneSignal.init with appId=null -> InvalidAppIdError. | ||
| const DEFAULT_APP_ID = 'b79087eb-8531-4d2d-a6f5-726f797891c7'; | ||
| let appId = getUrlQueryParam('app_id'); | ||
| try { | ||
| if (appId) localStorage.setItem('sdk4336_app_id', appId); | ||
| else appId = localStorage.getItem('sdk4336_app_id'); | ||
| } catch (e) {} | ||
| appId = appId || DEFAULT_APP_ID; | ||
|
|
||
| const SERVICE_WORKER_PATH = 'push/onesignal/'; | ||
|
|
||
| var OneSignalDeferred = window.OneSignalDeferred || []; | ||
| OneSignalDeferred.push(async function (OneSignal) { | ||
| const t0 = performance.now(); | ||
| await OneSignal.init({ | ||
| appId, | ||
| serviceWorkerParam: { scope: '/' + SERVICE_WORKER_PATH }, | ||
| serviceWorkerPath: SERVICE_WORKER_PATH + 'OneSignalSDKWorker.js', | ||
| }); | ||
| const elapsed = Math.round(performance.now() - t0); | ||
| console.log(`!!!! [SDK-4336 PAGE A] OneSignal initialized (${elapsed}ms)`); | ||
| }); | ||
|
|
||
| async function requestNotificationPermission() { | ||
| window.OneSignalDeferred = window.OneSignalDeferred || []; | ||
| OneSignalDeferred.push(async function (OneSignal) { | ||
| await OneSignal.Notifications.requestPermission(); | ||
| }); | ||
| } | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <h1>SDK-4336 Repro: Page A</h1> | ||
| <p> | ||
| <a href="./pageB.html">Go to Page B</a> | ||
| </p> | ||
| <p> | ||
| <button onclick="requestNotificationPermission()">Register</button> | ||
| </p> | ||
| <p>Repro steps (per the ticket):</p> | ||
| <ol> | ||
| <li>Add to Home Screen and open Page A.</li> | ||
| <li>Tap "Go to Page B".</li> | ||
| <li>Tap "Go to Page A".</li> | ||
| <li>Tap "Register" and accept the prompt.</li> | ||
| <li>Tap "Go to Page B".</li> | ||
| <li>Tap "Go to Page A" — <code>init()</code> should hang.</li> | ||
| </ol> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>SDK-4336 Repro: Page B</title> | ||
| <link rel="shortcut icon" href="#" /> | ||
| <link rel="manifest" href="manifest.json" /> | ||
| <meta name="apple-mobile-web-app-capable" content="yes" /> | ||
| <meta name="apple-mobile-web-app-status-bar-style" content="default" /> | ||
| <meta name="apple-mobile-web-app-title" content="SDK4336" /> | ||
| </head> | ||
| <body> | ||
| <h1>SDK-4336 Repro: Page B</h1> | ||
| <p> | ||
| <a href="./pageA.html">Go to Page A</a> | ||
| </p> | ||
| <p> | ||
| This page intentionally does <em>not</em> initialize the SDK. It just navigates back to Page A | ||
| so we can exercise the multi-page navigation flow described in SDK-4336. | ||
| </p> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.