Repository navigation
fix(ios): return from safari webview goto once the new page has replaced the old one - #519
Merged
Merged
Conversation
|
Warning Review limit reached
This review includes 2 billable files and costs up to $0.50. Or wait 49 minutes for your next included review. View limit details
Comment |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug
webview gotoon a Safari tab returned as soon as the navigation was requested. Awebview waitissued right after it polleddocument.readyStateon the page being left, found itcomplete, and returned in ~100ms.webview urlthen still showed the old page.Re-verified on current main (9243a76), iPhone 17 Pro simulator, Safari, against a local page that answers after 3s:
Reproduced 3 out of 3 times.
Android Chrome (CDP) is not affected.
Page.navigateonly answers once the new document has committed. On a Pixel 5 withhttps://httpbin.org/delay/3,gototook 3.7–4.3s,wait~0.5s, andurlwas the new page every time (3 runs). That code is unchanged.Root cause
WebKit's inspector protocol has no navigate command, so
safariWebViews.WebViewGotoevaluateswindow.location.href = urlin the page and returns. Nothing tied the laterwaitto that navigation.waitchecks "the current document is loaded", and until the new document commits, the current document is still the old one.Fix
gotonow returns only once the new page has replaced the old one, so whatever runs after it (wait,url,eval, ...) sees the new document:window.__mobilecliGoto). The mark lives only on that document.gotothen polls the tab until a document without that mark answers, meaning the navigation has committed. The id is new for every goto, so a reload of the same URL is also detected.javascript:URL never replace the page, so the script removes the mark right away andgotoreturns immediately.waitalready had is extracted intowaitUntiland shared. It has the same per-poll liveness timeout, ends early only for an unknown tab, and its timeout errors are unchanged forwait.gotofails withnavigation to <url> did not replace the page within 30s. Example: an unreachable host, where Safari keeps the old document. Before, this case returned ok and the followingwaitsucceeded against the old page.Verification
Live on the iPhone 17 Pro simulator (Safari), isolated daemon:
waitstill waits for load)#a,#top)javascript:void(0)go test ./...passes.make lintadds no new findings (38, all pre-existing).webview on safaripasses (9/9). I tried an e2e test for "url is new right after goto", but the sample page commits faster than the CLI round-trip, so it passes on main too. I left it out rather than add a test that doesn't discriminate.Not changed
The embedded-webview agents (Android
loadUrl, iOS agents) also return from goto before the new page commits. They are prebuilt agents, and this issue covers the Chrome/Safari tab paths reworked in #488/#489/#490.Fixes MOB-93