[webview_flutter_lwe] Add integration test based on upstream v4.13.1#1056
[webview_flutter_lwe] Add integration test based on upstream v4.13.1#1056seungsoo47 wants to merge 6 commits into
Conversation
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.
There was a problem hiding this comment.
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.
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).
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:
onUrlChangefor the navigation delegate.Bumped version 0.4.1 → 0.4.2.
All tests pass on TV/RPi4 emulator or device