webview_core 1.1.0
webview_core: ^1.1.0 copied to clipboard
Zero-dependency native WebView plugin for Flutter across Android, iOS, Linux, macOS, Windows, and Web. Replaces webview_flutter and webview_all with Wasm support.
1.1.0 #
Runtime stability release. Fixes native views that stopped responding after being hidden and shown again, restores in-page clicks on freshly mounted previews, adds the missing right-click menu on Windows, and ships a real-native integration test suite.
Fixed #
- macOS: native
WKWebViewwas permanently destroyed when Flutter hid it. The v1.0.0 teardown that reacted toviewDidMoveToSuperviewalso fired when the Flutter engine temporarily detached the platform view (IndexedStack,Offstage, collapsing panels, frames without a platform-view layer). The page was stopped, its delegate and script handlers were removed, and every later call (loadHtmlString,evaluateJavaScript,reload, …) silently returnednull, leaving an unresponsive view that only recovered after the user chose Reload. The bridge is now owned by the view (view → bridge,bridge ⇢ viewweak) and is released only when Flutter releases the view orWebViewController.dispose()is called. - macOS:
SIGABRTcrash (FlutterViewController dispatchMouseEvent:phase:) when scrolling a trackpad while a native context menu is open or crossing theWKWebView/FlutterViewboundary mid-gesture. WhenWKWebView's right-click menu (NSMenuTrackingSessionabove WebKit's-fno-exceptionsC++ stack) or the web view itself consumedNSEvent.Phase.beganbefore subsequent.changed/.ended/.stationaryscroll events landed onFlutterView,FlutterViewController.mmthrew an unhandledNSInternalInconsistencyException(@"Received gesture event with unexpected phase"— active even in Release builds), causingobjc_exception_rethrowto hitstd::__terminate(). AnNSRespondergesture-phase guard onFlutterViewControllernow filters unstarted and menu-tracking trackpad phases while keeping normal trackpad, momentum, and discrete wheel scrolling intact without requiring hostMainFlutterWindowchanges. - macOS:
evaluateJavaScript('1+1')returned'2.0'instead of'2'; integral JavaScript numbers are now delivered as integers on every platform. - Windows: no context menu. Composition hosting never renders the default WebView2 menu. Right-click now shows the Edge menu (Back, Forward, Reload, Copy, …) as a native popup through
ContextMenuRequested. - Windows: keyboard focus trap. The WebView host consumed every key.
Tab,F1–F12,Escape, modifier-only presses, andWincombinations now stay with Flutter so focus traversal and application shortcuts keep working. - All desktop and iOS:
target="_blank"links andwindow.open()were silently dropped (macOS, iOS, Linux) or handled by an external popup (Windows).http(s)targets now open in place. - Windows: intermittent native crash (
0xC0000005influtter_windows.dll) on startup and while resizing. The texture callbacks captured a rawthis, and shared D3D textures were destroyed on every resize while the Flutter raster thread could still import them by handle. Frame state is now reference counted, replaced textures are kept alive for 3 s, and all textures are handed to the engine's unregister callback on dispose. (Crashed in 2 of 5 integration-test runs before the fix, 0 of 9 after.) - Windows: right-click menu froze the view or opened at monitor
(0, 0). ShowingTrackPopupMenusynchronously insideContextMenuRequestedstalled every later native call (evaluateJavaScript, channels) until the menu closed, while queueing the deferred popup throughCreateDispatcherQueueControllerfailed in host applications where another plugin already owned the UI thread'sDispatcherQueue, leavingContextMenuRequestedunhandled so WebView2 clamped its fallback popup to(0, 0). The handler now captures the screen cursor position at right-click time, marks the event handled on every exit path, and dispatches the deferredTrackPopupMenuthrough a Win32HWND_MESSAGEtask runner on the platform thread. - Windows:
loadHtmlString(baseUrl:)produced an opaque origin. The document ran asabout:blank, sodocument.cookie,localStorageand same-origin requests threwSecurityError. An http(s)baseUrlis now served as that URL, so the page gets the real origin (matching macOS, iOS and Android). - Windows:
WebViewCookieManager.setCookiebefore the first view was dropped. Cookies are now queued and applied to the first view that is created. - Windows: mouse click inside the WebView froze host UI input. Parenting
ICoreWebView2CompositionControllerdirectly toFLUTTERVIEWand callingcontroller_->MoveFocusduringonPointerDownlet WebView2's internalChrome_WidgetWin_0child HWND steal Win32 focus and mouse capture beforeWM_LBUTTONUP, wedging pointer delivery untilput_IsVisible(FALSE)hid the controller. Composition controllers now use an isolated off-client host HWND,FLUTTERVIEWis guarded againstWM_KILLFOCUS/WM_CAPTURECHANGEDtheft from internal WebView2 HWNDs, andPointerCancelEventreleases any active mouse buttons beforeleave. - Linux: mounting a WebView stalled the Flutter 3.50+ engine or crashed on Wayland + NVIDIA. Removing an already-realized
FlView(GtkBox) fromGtkWindowto wrap it inGtkOverlaytriggeredfl_view_unrealize, stopping the Dart UI isolate, while WebKitGTK's default DMA-BUF renderer terminated the host process with Wayland protocol error 71 on NVIDIA drivers, and aGDK_WINDOW_CHILDoverlay painted behindFlViewRendererSubsurface.GtkOverlayis now packed insideFlViewviagtk_widget_reparentwithout unrealizingFlView,WEBKIT_DISABLE_DMABUF_RENDERER=1is set by default beforeWebKitWebContextinitialization, and the viewport clip container realizes as a transientGDK_WINDOW_SUBSURFACEon Wayland (GDK_WINDOW_CHILDon X11) so the WebView renders aboveFlViewRendererSubsurfacewith working right-click popup menus. - Linux: keyboard and mouse input froze after clicking the WebView, dragging splitters, opening popups, or shifting
RepaintBoundaryancestors. ClickingWebKitWebViewmoved GTK focus away fromFlViewwhileFlView'sGtkEventBox(can_focus = false) never reclaimed it on click andsetGeometry(visible: false)leftGtkWindowunfocused; ancestor layout shifts and partial popup overlays did not triggersetGeometrywhen the WebView sat inside aRepaintBoundary; andreload()afterloadHtmlString(..., baseUrl:)fetchedbaseUrlover the network instead of re-rendering the inline HTML. Clicking Flutter's surface or hiding/disposing a focused WebView now immediately restores GTK focus toFlView(F1–F12andSupershortcuts also pass through), geometry and partial/full popup occlusion sync after every rendered frame without idle polling, active Flutter pointer drags enable temporary overlay pass-through, andreload()(including the native context menu item) preserves inlineloadHtmlStringdocuments.
Added #
- macOS / iOS: automatic recovery from a crashed
WebContentprocess. The failure is reported throughNavigationDelegate.onWebResourceError(WebResourceErrorType.webContentProcessTerminated) and the page is reloaded. - Native integration tests (
example/integration_test/): hide / show cycles, remounts, rounded-clip resize storms, debounced typing storms, JavaScript channels, navigation prevention, cookies,target="_blank", and the example application itself, executed against the real platform plugin (flutter test integration_test -d macos). - Windows host key-policy unit test.
- Redesigned example application with an HTTP response preview, a Mail composer live preview that proves editor text is never modified by preview theming, and a Diagnostics tab (UI heartbeat, native round-trip probe, stress actions, event log).
1.0.0 #
Initial stable release of webview_core — a unified, zero-dependency native WebView plugin for Flutter across Android, iOS, Linux, macOS, Windows, and Web / WebAssembly (dart2wasm).
Zero-Dependency 6-Platform Architecture #
- Eliminates all external hosted Pub, CocoaPods/SwiftPM, Gradle/Maven, and NuGet CLI dependencies (
dependencies:contains only Flutter SDK packages:flutterandflutter_web_plugins), replacing fragmented federated WebView packages with a single self-contained plugin built onpackage:flutter/widgets.dart. - Android (
Kotlin/android.webkit.WebView, minSdk 24, compileSdk 36, AGP 8.x & 9.x Built-in Kotlin compatible): Zero-androidxPlatformViewFactoryimplementation using UTF-8loadDataWithBaseURL, synchronous-halt + async-decisionNavigationDecision.preventenforcement, custom-header and non-GETloadRequestsupport, CSS logical-pixel scroll synchronization,CookieManagerintegration,@JavascriptInterfacechannels, and zero deprecated APIs. - iOS (
Swift/WKWebView, iOS 14.0+): Dual Swift Package Manager (Package.swift) and CocoaPods (webview_core.podspec) layout withPrivacyInfo.xcprivacy,WKWebpagePreferences.allowsContentJavaScript,isOpaque = falsebackdrop synchronization, weak instance registry for automaticUiKitViewunmount cleanup,WKHTTPCookieStoresupport, and zero deprecated APIs. - Linux (
C++14/GTK3&webkit2gtk-4.1): Compiles cleanly under Flutter's standardcxx_std_14CMake settings and Ubuntu 22.04 (GLib 2.72.4) headers, combiningGtkLayoutviewport clipping insideGtkOverlaywith automaticVisibility/RenderIndexedStack/Offstage/ modal-route andhitTestInViewocclusion tracking,destroy-signal lifecycle guards, zoom-lock scripts, andWebKitCookieManagersupport. - macOS (
Swift/WKWebView, macOS 11.0+): Dual Swift Package Manager (Package.swift) and CocoaPods (webview_core.podspec) layout withPrivacyInfo.xcprivacy, fullsetBackgroundColorsupport via directInteractiveWKWebViewAppKitViewhit-testing anddrawsBackground = false+CALayer/underPageBackgroundColorbackdrop, automatic superview detach cleanup, and zero deprecated APIs. - Windows (
C++17/WRL&WebView2LoaderStatic.libx64/ARM64,/W4 /WX&_HAS_EXCEPTIONS=0clean): Downloads and verifies the officialMicrosoft.Web.WebView2archive directly in CMake withoutnuget.exeorWIL, compositingICoreWebView2CompositionControllerframes via zero-copy DXGI shared GPU textures (FlutterDesktopGpuSurfaceDescriptor, with automaticPixelBufferTexturefallback on software adapters), supporting> 2 MBHTML documents via in-memoryWebResourceRequestedstreams, and forwarding HiDPI bounds, keyboard shortcuts, and pointer modifiers. - Web & WebAssembly (
dart:js_interop/dart:ui_web,dart2wasmclean): Conditional-import architecture isolatingdart:iofrom Web, featuring pure SDKdart:js_interopHTMLIFrameElementrendering (srcdoc,src,sandbox, Standards-Mode<!DOCTYPE>preservation, CSSrgba()background, andcontentWindow-verifiedpostMessagechannels).
Compatibility Barrels & Core Types #
package:webview_core/webview_core.dart: Primary API exportingWebViewController,WebViewWidget,WebView,WebViewCookieManager,WebViewCookie,JavaScriptMode,LoadRequestMethod,NavigationDelegate,NavigationDecision,NavigationRequest,WebResourceError,WebResourceErrorType,UrlChange, andJavaScriptMessage.package:webview_core/webview_flutter.dart: Compatibility barrel for corewebview_flutterAPIs.package:webview_core/webview_all.dart: Compatibility barrel forwebview_allAPIs.