Skip to content

fix: delegate ShouldInterceptRequest in DevFlowWebViewClient#102

Merged
Redth merged 1 commit into
mainfrom
fix/devflow-webviewclient-intercept
Apr 19, 2026
Merged

fix: delegate ShouldInterceptRequest in DevFlowWebViewClient#102
Redth merged 1 commit into
mainfrom
fix/devflow-webviewclient-intercept

Conversation

@PureWeen
Copy link
Copy Markdown
Member

Problem

DevFlowWebViewClient (added in 2c05e68) replaces MAUI's WebKitWebViewClient on Android to detect page navigation and re-inject chobitsu. However, it only delegates OnPageFinished and ShouldOverrideUrlLoading — it does not delegate ShouldInterceptRequest.

MAUI's WebKitWebViewClient.ShouldInterceptRequest() is the mechanism that serves local wwwroot/ assets (CSS, JS, images) via the https://0.0.0.1/ custom scheme. Without delegation, the base WebViewClient returns null ("don't intercept"), so all asset requests fail — the WebView tries to fetch from 0.0.0.1 over the network, which doesn't exist.

Symptoms

  • index.html loads (served separately as HostPage) but all CSS/JS fail
  • document.styleSheets.length === 0, typeof Blazor === "undefined"
  • App stuck on splash/loading screen
  • Affects any MAUI Blazor Hybrid app using AddMauiBlazorDevFlowTools() on Android

Affected versions

  • Working: 0.1.0-preview.4.26202.3
  • Broken: 0.1.0-preview.5.26217.12

Fix

Add ShouldInterceptRequest override that delegates to the inner client, matching the existing pattern used for ShouldOverrideUrlLoading.

Fixes #101

DevFlowWebViewClient replaces MAUI's WebKitWebViewClient on Android
but was not delegating ShouldInterceptRequest to the inner client.
This broke local asset serving for all Blazor Hybrid apps because
MAUI's ShouldInterceptRequest is the mechanism that serves wwwroot/
assets via the https://0.0.0.1/ custom scheme.

Without this delegation, all CSS and JS asset requests fail (the base
WebViewClient returns null = 'don't intercept'), Blazor never
initializes, and the app is stuck on the loading screen.

Fixes #101

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 19, 2026 14:21
Copy link
Copy Markdown
Contributor

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.

Pull request overview

Fixes Android Blazor Hybrid asset loading regressions introduced by DevFlowWebViewClient by delegating ShouldInterceptRequest to MAUI’s original inner WebViewClient, allowing MAUI’s https://0.0.0.1/ asset interception to work as intended.

Changes:

  • Add ShouldInterceptRequest override in DevFlowWebViewClient that delegates to the existing inner client (falling back to base).
  • Preserve existing delegation pattern already used for ShouldOverrideUrlLoading.

@Redth Redth merged commit 0787bbc into main Apr 19, 2026
7 checks passed
@Redth Redth deleted the fix/devflow-webviewclient-intercept branch April 19, 2026 19:15
@MauiBot
Copy link
Copy Markdown

MauiBot commented Apr 19, 2026

No documentation updates needed — this is an internal bug fix (delegating ShouldInterceptRequest to the inner WebViewClient) with no public API or user-facing behavioral changes.

Generated by PR Documentation Check for issue #102 ·

PureWeen added a commit to PureWeen/PolyPilot that referenced this pull request Apr 20, 2026
…OS & Android (#639)

## Summary

Fixes the session context menu (⋯ button) on mobile devices. The menu
was completely unusable on both iOS and Android — tapping ⋯ switched
sessions, the menu couldn't scroll, and the keyboard appeared
unexpectedly.

## Changes

### DevFlow Revert
- **Reverted MauiDevFlow.Blazor to preview.4** — preview.5 breaks
BlazorWebView asset serving on Android (missing `ShouldInterceptRequest`
delegation). Filed
[dotnet/maui-labs#101](dotnet/maui-labs#101)
and [PR #102](dotnet/maui-labs#102).

### ⋯ Button Session Selection Fix
- **Root cause**: A capture-phase JS click handler in `index.html`
called `JsExpandSession` on ANY click inside a `.session-item`,
including ⋯ button and menu items. This switched sessions on every menu
interaction.
- **Fix**: Added early return for `.more-btn`, `.session-menu`, and
`.menu-overlay` clicks.
- Moved `@onclick` from `session-item` to `session-info` div so the ⋯
button area is structurally excluded.

### iOS Ghost Click Prevention
- On iOS, tapping ⋯ caused a ghost touch on the `flyout-backdrop` behind
the menu overlay. A capture-phase JS handler now blocks backdrop events
within 1s of a menu interaction via `stopImmediatePropagation`.

### iOS Keyboard Dismissal
- `ToggleFlyout` now calls `activeElement.blur()` to dismiss the
keyboard when the flyout opens.
- `positionSessionMenu` also blurs on menu open.
- Added `user-select: none !important` on `.menu-item` to prevent iOS
WebKit from treating `all: unset` buttons as editable.

### Menu Scroll (iOS & Android)
- **Portal to body**: On mobile, `positionSessionMenu` moves the menu
DOM to `document.body` to escape the flyout's CSS `transform` stacking
context. iOS WebKit cannot natively scroll `position: fixed` elements
inside a transformed parent.
- **Safe area insets**: Menu `maxHeight` now probes
`env(safe-area-inset-top/bottom)` on iOS (via temp element) and reads
`--nav-bar-height`/`--status-bar-height` on Android.
- **Freeze parent scroll**: Flyout and session-list `overflow` set to
`hidden` while menu is open; restored via `MutationObserver` on menu
removal.

## Testing
- Verified on physical Samsung S24 (Android) via ADB real taps + DevFlow
CDP
- Verified on physical iPhone 15 Pro Max (iOS) via MauiDevFlow CDP
- Mac Catalyst builds clean (no regression)

## Files Changed
- `PolyPilot/wwwroot/index.html` — JS capture handlers,
positionSessionMenu portal + safe area
- `PolyPilot/Components/Layout/SessionListItem.razor` — moved onclick,
simplified handlers
- `PolyPilot/Components/Layout/SessionListItem.razor.css` — menu scroll
CSS
- `PolyPilot/Components/Layout/MainLayout.razor` — flyout keyboard
dismiss, backdrop guard
- `PolyPilot/PolyPilot.csproj` — DevFlow revert to preview.4
- `PolyPilot.Gtk/PolyPilot.Gtk.csproj` — DevFlow revert to preview.4

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DevFlowWebViewClient breaks BlazorWebView asset serving on Android

4 participants