Skip to content

[webview_flutter_lwe] Add integration test based on upstream v4.13.1#1056

Open
seungsoo47 wants to merge 6 commits into
flutter-tizen:masterfrom
seungsoo47:webview_flutter_lwe-add-integration-tests
Open

[webview_flutter_lwe] Add integration test based on upstream v4.13.1#1056
seungsoo47 wants to merge 6 commits into
flutter-tizen:masterfrom
seungsoo47:webview_flutter_lwe-add-integration-tests

Conversation

@seungsoo47

@seungsoo47 seungsoo47 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Port the 'can receive url changes' NavigationDelegate integration test from upstream webview_flutter v4.13.1, and fix three bugs found while making it pass on Tizen:

  • Implement onUrlChange for the navigation delegate.
  • Fix navigation delegate callbacks being dropped after the delegate is replaced.
  • Fix a raster thread crash on WebView disposal (TBM surface freed while still being composited).
  • Fix a use-after-free when async callbacks run after the WebView is disposed.

Bumped version 0.4.1 → 0.4.2.

Note: This PR depends on the corresponding embedder and LWE PRs and must be merged only after those are applied.

All tests pass on TV/RPi4 emulator or device

The lightweight web engine has no dedicated URL-change callback, so report a
URL change from the page-started handler: the native side now also invokes
onUrlChange with the navigation URL, and LweNavigationDelegate.setOnUrlChange
stores the callback and forwards the onUrlChange channel event instead of
throwing UnimplementedError.

Bump version to 0.4.2.
Port the 'can receive url changes' NavigationDelegate test from upstream
webview_flutter v4.13.1, now runnable thanks to the onUrlChange implementation.

Other upstream tests not present in this suite remain omitted because the
lightweight web engine does not support the required features (custom request
headers, HTTP error status callback, HTTP basic auth, web storage clearing,
window.open, and media playback policy).
…e replacement

When the navigation delegate is replaced after the WebView is created, the new
delegate's platform channel handler was never registered because it is only set
up when the view is first created. As a result the new delegate's callbacks
(onUrlChange, onPageFinished, onProgress, etc.) were still delivered to the
previous delegate and silently dropped.

Bind the new delegate's channel handler when the delegate is set after the view
has been created, and guard the handler setup so a delegate is bound at most
once. This makes onUrlChange work when a delegate is swapped, which the
'can receive url changes' integration test exercises.
Disposing a WebView unregistered the texture and then immediately destroyed the
web engine and its TBM surfaces on the same call. The Flutter raster thread
could still be compositing the last frame that referenced a TBM surface, so the
surfaces were freed out from under the GPU (tbm_bo_free with a non-zero lock
count), crashing the raster thread.

Dispose now stops the web engine first, unregisters the texture, and blocks the
raster thread from obtaining or touching buffers via a disposing flag. Because
the Tizen embedder does not invoke the UnregisterTexture completion callback,
the TBM surfaces are released on a later main-loop turn (ownership is moved out
of the WebView) so any in-flight composite finishes first.

This eliminates the raster-thread crash seen when running the integration test
suite, where each test disposes a WebView.
… callbacks

The navigation-delegate callbacks (onPageStarted/onUrlChange, onPageFinished,
onProgress, onWebResourceError, navigationRequest) and the JavaScript-channel
callback are dispatched to the main loop asynchronously, and the
navigationRequest result is resolved asynchronously by the Dart side. Any of
them could run after the WebView was disposed and dereference the destroyed
WebView (and its now-freed method channels), causing a use-after-free.

Add a shared is_alive_ flag that Dispose() clears; every deferred callback
captures a copy and bails out when the WebView is gone, and
NavigationRequestResult checks it before touching the WebView.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements onUrlChange for the navigation delegate, fixes navigation delegate callback dropping when replaced after WebView creation, and addresses crashes and use-after-free issues during WebView disposal. Feedback was provided regarding a potential LateInitializationError in LweNavigationDelegate.onCreate if the platform view is recreated, as the _navigationDelegateChannel is declared as late final and cannot be re-assigned.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/webview_flutter_lwe/lib/src/lwe_webview_controller.dart
The navigation-delegate and JavaScript-channel callback lambdas added in the
preceding commits were not clang-format clean, failing the repository's format
CI check. Reflow them to match clang-format (Google style).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant