Repository navigation
[iOS/Mac] BlazorWebView: reload the requested page when the web content process ends before it starts loading - #40455
Conversation
…nt process ends before it starts loading When the web content process ends before the requested page's navigation starts, WebKit has already cleared the web view's URL and back-forward item by the time ContentProcessDidTerminate is called. WebContentProcessReloader then fell back to Reload(), which had nothing to load, so the page never loaded (WebContentProcessTerminationBeforeFirstPageLoadsLoadsThatPageAgain). WebKit itself loads its pending API request URL again in that case (WebPageProxy::tryReloadAfterProcessTermination). Remember the page asked for with LoadRequest until its navigation starts, and load it again. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
…eload request When the page navigates by itself (location.href) after a manager-requested load, the reloader must recover to the page the web view navigated to, not to the stale requested URL. Fails if NavigationStarted stops clearing _requestedPageUrl. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 4bb40d5.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target Branch
mainnet11, for reviewThis targets
candidate/11.0.1xx-sr2, the same base as #40419.WebContentProcessReloaderexists only on the SR2 candidate; it is not innet11ormain.For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
BlazorWebViewTests.WebContentProcessTerminationBeforeFirstPageLoadsLoadsThatPageAgainwas added in #40419. It fails on iOS for both the Mono and CoreCLR legs of the candidate's device-test build 1690816 (head 8e70055):Root cause. The test ends the web content process from
UrlLoading, which runs insideDecidePolicyfor the first navigation, before that navigation starts. By the timeContentProcessDidTerminateis called, WebKit has already reset its page load state (PageLoadState::reset), soWKWebView.UrlandBackForwardList.CurrentItemare bothnull.WebContentProcessReloader.TryReloadassumed that "the page that was being loaded is still the web view's URL". It therefore fell back toReload(), which has nothing to load, and the page never loaded.Temporary diagnostics confirmed this on an iOS 26.0 simulator. For this test the callback saw
url=<null> current=<null> visible=True, so the reload ran immediately (no window wait) and still had no URL.WebKit avoids this with its own pending API request.
WebPageProxy::tryReloadAfterProcessTerminationloadspendingAPIRequestURLagain when it is set, and callsreload()only otherwise.pendingAPIRequestis set byloadRequestand cleared when that navigation starts (didStartProvisionalLoadForFrame). It isn't exposed throughWKWebView.Fix.
WebContentProcessReloadermirrors WebKit's pending API request.PageRequestedremembers the page MAUI last asked for withLoadRequest, andNavigationStarted(DidStartProvisionalNavigation) forgets it.TryReloadloads that page again when it is still pending. Otherwise it keeps the existing behavior: loadUrlwhen there's no committed page, elseReload().IOSWebViewManagercallsPageRequestedfor both of itsLoadRequestcalls: the start page inNavigateCore, and the app-scheme redirect re-issue.NavigateCoredisposes itsNSUrl.Intentional difference from WebKit: WebKit also drops the pending request when the policy decision ignores that navigation. Here the page stays pending until a navigation starts. If the app cancels its start page in
UrlLoadingand the process later ends before any navigation starts, the reload asks for that page again. It still goes throughDecidePolicy/UrlLoading, so the app's decision still applies.Causal evidence. iOS 26.0 iPhone 11 Pro simulator, Xcode 27.2. Each run used the full
BlazorWebViewdevice-test suite:'<null>'error as CI), 1 skippedAll six
WebContentProcessTermination*tests pass with the fix:RaisesProcessTerminatedAndReloadsVisiblePageReloadsHiddenPageOnceItIsInAWindowRightAfterReloadDoesNotReloadAgainLongAfterReloadReloadsAgainBeforeFirstPageLoadsLoadsThatPageAgainAfterThePageNavigatedByItselfReloadsTheNewPage(added in 4bb40d5 after review; fails ifNavigationStarteddoesn't clear the pending request, otherwise 63 passed, 0 failed, 1 skipped)dotnet format whitespace --verify-no-changespasses on both files. MacCatalyst shares this code (iOS/folder) and was not run locally. In build 1690816 its BlazorWebView work items passed 62/63 at 8e70055 without this change, on macOS 15 (Helix c7a22071) and macOS 26 (Helix cf4220c0), so only iOS shows the failure. This PR's CI covers MacCatalyst with the change.CI on merge 151ca05: maui-pr 1691141 succeeded. Device tests 1691443 succeeded with 0 failed tests in all 9 runs (Android, iOS, MacCatalyst, Windows). All six tests above pass in the iOS Mono and CoreCLR runs on macOS 15 and 26 and in both MacCatalyst runs. Without this change, a rerun of 1690816's failed jobs at 8e70055 failed the same test again: across both attempts it failed 4 of 4 iOS runs on macOS 26 and 1 of 4 on macOS 15.
Issues Fixed
No separate issue is logged. This is a follow-up to #40419, found while auditing the SR2 candidate (#40116).