Skip to content
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

[HybridWebView] Always complete web requests #28286

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Mar 10, 2025

Description of Change

Currently iOS and Mac Catalyst only complete the requests if they are successful. This PR updates the logic to make sure to always complete the requests so the app can continue. Any async fetches will now complete, allowing the JS to continue.

Windows and Android already do this and I added a test for this in #28230, however Mac Catalyst was very iffy and we merged thinking it was the CI ghosts. Turns out, CI was sending the right messages and we trusted AI too much.

Issues Fixed

Fixes #28285

@Copilot Copilot bot review requested due to automatic review settings March 10, 2025 17:57
@mattleibow mattleibow requested a review from a team as a code owner March 10, 2025 17:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR ensures that all web requests in HybridWebView complete regardless of success, preventing stalls in asynchronous JS operations. Key changes include:

  • Adding HybridWebView developer tools in debug builds in MauiProgramDefaults.
  • Updating the iOS HybridWebViewHandler to always return a 404 response with a consistent message when requests fail, eliminating early exits.
  • Removing the conditional error logging branch in StartUrlSchemeTask to guarantee request completion.

Reviewed Changes

File Description
src/Core/tests/DeviceTests.Shared/MauiProgramDefaults.cs Added registration of developer tools in debug builds to support HybridWebView functionality.
src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.iOS.cs Modified response handling to always complete web requests using a lazy 404 message and removed error logging branch.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Core/src/Handlers/HybridWebView/HybridWebViewHandler.iOS.cs:155

  • Ensure there are automated tests covering the new behavior for non-200 responses in HybridWebViewHandler.iOS.cs. Verify that TestCases.HostApp and TestCases.Shared.Tests include cases that validate the consistent completion of web requests.
if (statusCode == 200)

@PureWeen PureWeen added this to the .NET 9 SR5 milestone Mar 10, 2025
@PureWeen PureWeen merged commit 4979724 into main Mar 11, 2025
125 of 129 checks passed
@PureWeen PureWeen deleted the dev/hybridwebview-fix-maccat branch March 11, 2025 12:54
@mattleibow
Copy link
Member Author

/backport release/9.0.1xx-sr4

@mattleibow
Copy link
Member Author

/backport to release/9.0.1xx-sr4

Copy link
Contributor

Started backporting to release/9.0.1xx-sr4: https://github.com/dotnet/maui/actions/runs/13790493864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Catalyst Device Tests are broken from [HybridWebView] Properly managed response streams
4 participants