Web and OpenHarmony (ArkWeb) Implementations
Two very different engines sit at the edges of the ZikZak InAppWebView federated model: the browser DOM (via an <iframe>) and OpenHarmony’s system ArkWeb (via a native ArkTS Web component). Both plug into the same InAppWebViewPlatform contract that every other platform implements, yet they reach it from opposite directions — one is a pure-Dart package compiled to JavaScript with no native layer at all, and the other is a full native HAR module written in ArkTS. This page explains how each one wires into the platform interface, how rendering and the controller bridge work, and — crucially — where the capabilities diverge from the “full” mobile/desktop implementations. Understanding these two backends is the key to knowing what your app can and cannot rely on when it targets the web or an OpenHarmony device.
Sources: zikzak_inappwebview_web.dart platform.dart
Two Engines, One Contract
Section titled “Two Engines, One Contract”Although the two packages look nothing alike internally, they share a single architectural obligation: register an InAppWebViewPlatform instance so the umbrella package’s public factories resolve to them. The diagram below shows where each sits relative to the shared contract and the native/engine layer beneath it.
graph TD App["Application code<br/>InAppWebView / Controller / CookieManager"] PI["InAppWebViewPlatform<br/>(platform_interface)"] Web["ZikzakInAppWebViewWebPlatform<br/>(Dart → JS)"] Ohos["OhosInAppWebViewPlatform<br/>(Dart)"] Iframe["HTMLIFrameElement<br/>+ ui_web view factory"] ArkWidget["OhosView<br/>wtf.zikzak/arkweb"] ArkNative["ArkWebView.ets<br/>(ArkTS PlatformView)"] Engine1["Browser rendering engine"] Engine2["System ArkWeb engine"]
App --> PI PI --> Web PI --> Ohos Web --> Iframe --> Engine1 Ohos --> ArkWidget --> ArkNative --> Engine2The endorsement status is the first structural difference. The web package is endorsed — the umbrella declares default_package: zikzak_inappwebview_web, so it is pulled in automatically and you never import it directly. The OpenHarmony package is unendorsed: it is not in the umbrella’s dependency list, so you must add zikzak_inappwebview_ohos to your app yourself, and OHOS Flutter auto-registers OhosInAppWebViewPlatform through its dartPluginClass. This distinction shapes the entire developer experience of each target.
Sources: pubspec.yaml README.md pubspec.yaml
| Dimension | Web (_web) |
OpenHarmony (_ohos) |
|---|---|---|
| Endorsement | Endorsed (auto-included) | Unendorsed (add manually) |
| Implementation language | Pure Dart → JS (package:web, dart:js_interop) |
Dart + native ArkTS (.ets) HAR |
| Rendering primitive | HTMLIFrameElement |
ArkUI Web component via OhosView |
| Registration entry | registerWith(Registrar) |
dartPluginClass + pluginClass |
| Transport to engine | Direct DOM/JS interop | MethodChannel with JSON strings |
| Runtime requirement | Any modern browser | OHOS Flutter 3.47+, API 23+ |
The Web Implementation: iframe-Backed Rendering
Section titled “The Web Implementation: iframe-Backed Rendering”Registration and Platform Wiring
Section titled “Registration and Platform Wiring”The web package follows the standard Flutter web plugin convention: a registerWith(Registrar) entry point assigns a fresh ZikzakInAppWebViewWebPlatform to InAppWebViewPlatform.instance. That platform object overrides exactly three factory methods — the inline widget, the find-in-page interaction controller, and the headless view — mirroring the subset of the contract that a browser can meaningfully support.
Sources: zikzak_inappwebview_web.dart in_app_webview_web_platform.dart
The Element and the View Factory
Section titled “The Element and the View Factory”InAppWebViewWebElement is the heart of web rendering. It creates a single HTMLIFrameElement, styles it to fill its parent, and instantiates an InAppWebViewWebController bound to that iframe. In build, it generates a unique view type string (keyed on windowId or a hash), registers a platformViewRegistry view factory that returns the iframe, and wraps it in an HtmlElementView. The initial load source is resolved in the constructor in a fixed priority — initialUrlRequest, then initialFile, then initialData — before onWebViewCreated fires. Disposal is guarded by a _disposed flag so both the widget-level and owning-State teardown paths are idempotent.
Sources: in_app_webview_web_element.dart in_app_webview_web_element.dart
Controller Capabilities and the Cross-Origin Reality
Section titled “Controller Capabilities and the Cross-Origin Reality”The InAppWebViewWebController maps the platform controller surface onto iframe operations. Its defining characteristic is that every meaningful operation is wrapped in try/catch fallbacks because the browser’s same-origin policy blocks access to contentDocument/contentWindow for cross-origin frames. Navigation sets _iframe.src; HTML data uses srcdoc (deliberately, to keep the frame same-origin so console interception and JS evaluation still work); getUrl, getTitle, getHtml, reload, goBack/goForward, and evaluateJavascript all degrade gracefully when the frame is cross-origin. getHtml in particular tries three strategies in sequence — contentDocument, contentWindow.document, then raw JS interop — before returning null.
Sources: in_app_webview_web_controller.dart in_app_webview_web_controller.dart
| Controller method | Web behavior | Limitation |
|---|---|---|
loadUrl / loadFile / loadData |
Sets src / assets/ URL / srcdoc or data URI |
— |
getUrl / getTitle |
Reads contentWindow / contentDocument |
null when cross-origin |
evaluateJavascript |
Injects a <script> element |
Return value not captured |
reload / goBack / goForward |
contentWindow history/location |
No-op when cross-origin |
takeScreenshot / createPdf |
Stubs returning null |
Out of scope by spec |
getProgress |
Returns null |
Not supported on a bare iframe |
Sources: in_app_webview_web_controller.dart screenshot_pdf_delegation_test.dart
Console Interception and the JavaScript Bridge
Section titled “Console Interception and the JavaScript Bridge”Because a browser iframe has no native console pipe, the web controller synthesizes one. On each load, it injects a small script that overrides console.log/warn/error/debug/info to postMessage a JSON envelope to the parent window; the controller listens on window for those messages and forwards them to onConsoleMessage. The same window message channel backs the JavaScript handler bridge — addJavaScriptHandler registers a callback in a map and lazily installs a listener that dispatches by handlerName. Disposal clears the handler map and removes the listener, keeping the global window clean.
Sources: in_app_webview_web_controller.dart in_app_webview_web_controller.dart in_app_webview_web_controller.dart
Headless and Find-in-Page
Section titled “Headless and Find-in-Page”HeadlessInAppWebViewWeb reuses the same controller but appends an off-screen iframe (visibility:hidden, positioned at -9999px) to document.body, sizing it from initialSize and allowing runtime setSize/getSize. FindInteractionControllerWeb, by contrast, is an explicit no-op — all four methods are empty, so find-in-page silently does nothing on web.
Sources: headless_in_app_webview_web.dart find_interaction_controller_web.dart
The OpenHarmony (ArkWeb) Implementation
Section titled “The OpenHarmony (ArkWeb) Implementation”Dual Plugin Classes and the Dart Layer
Section titled “Dual Plugin Classes and the Dart Layer”OpenHarmony needs two registered classes, declared together in the package’s pubspec.yaml: a native pluginClass: ZikzakInAppWebViewPlugin (the ArkTS entry) and a dartPluginClass: OhosInAppWebViewPlatform (the Dart entry). On the Dart side, OhosInAppWebViewPlatform overrides the widget, controller (both instance and a 'static' variant), and cookie-manager factories. Its OhosInAppWebViewWidget renders an OhosView — a widget supplied by the OHOS Flutter SDK fork, used here without an explicit import — with view type wtf.zikzak/arkweb, passing settings, user scripts, and the initial load source as a JSON creationParams string. Notably, the widget refuses headless/keepAlive/windowId adoption, throwing UnsupportedError rather than pretending to support it.
Sources: pubspec.yaml platform.dart
The Dart Controller and Method-Channel Bridge
Section titled “The Dart Controller and Method-Channel Bridge”OhosInAppWebViewController speaks to native ArkWeb over a per-instance MethodChannel('wtf.zikzak/arkweb_$id'), passing every argument and result as a JSON string. The controller installs a method-call handler that decodes native events and fans them out to the app’s callbacks (onLoadStart, onProgressChanged, onReceivedError, shouldOverrideUrlLoading, permission prompts, and JS-handler calls). A notable piece of cross-platform engineering is _errorTypeFromCode, which maps ArkWeb’s net_error_list.h-style negative codes onto the shared WebResourceErrorType taxonomy so an app can distinguish DNS, timeout, and TLS failures instead of string-matching a description. Disposal is idempotent and, when not keep-alive, fires the native dispose while swallowing only MissingPluginException (a sign the platform-view owner already tore the native side down).
Sources: controller.dart controller.dart controller.dart
The Native ArkTS Layer and JavaScript Bridge
Section titled “The Native ArkTS Layer and JavaScript Bridge”The native side is where ArkWeb’s real work happens. ZikzakInAppWebViewPlugin registers the wtf.zikzak/arkweb view factory and a separate wtf.zikzak/arkweb_cookies channel backed by webview.WebCookieManager. ArkWebView.ets implements the PlatformView around an ArkUI Web component, wiring every declarative callback (onPageBegin, onProgressChange, onConsole, onErrorReceive, onShowFileSelector, etc.) back to Dart. The JavaScript bridge is injected at document-start as a BRIDGE script that installs globalThis.zikzak_inappwebview.callHandler and routes replies through a __zikzakArkWeb javaScriptProxy. The sequence below shows a page-initiated handler call and its asynchronous reply.
sequenceDiagram participant Page as Page JS participant Bridge as __zikzakArkWeb proxy participant Native as ArkWebView.ets participant Dart as OhosInAppWebViewController
Page->>Bridge: zikzak_inappwebview.callHandler('echo', args) Bridge->>Native: callHandler(JSON {handlerName,args,callId,documentId}) Native->>Dart: ask('onCallJsHandler', ...) Dart-->>Native: JSON-encoded return value Native->>Page: runJavaScript setTimeout → __zikzakArkWebReply(...) Note over Native,Page: Reply runs in a new task to avoid re-entering runJavaScriptSources: ZikzakInAppWebViewPlugin.ets ArkWebView.ets ArkWebView.ets ArkWebView.ets
The Navigation-Policy Replay Boundary
Section titled “The Navigation-Policy Replay Boundary”ArkWeb’s onOverrideUrlLoading veto callback is synchronous, but the public Dart navigation policy is asynchronous. The implementation reconciles this by cancelling and replaying only main-frame GET requests — preserving headers — while a generation counter invalidates any outstanding decision when a newer navigation arrives. POST bodies and subframe identities cannot be recovered from the native callback, so those requests continue natively and are never surfaced as cancellable async events. This is the single most important behavioral asymmetry to understand when porting navigation-guard logic to OpenHarmony.
Sources: ArkWebView.ets README.md
Cookie Management Without a Dart Mirror
Section titled “Cookie Management Without a Dart Mirror”OhosCookieManager deliberately does not mirror cookies in Dart. It formats a plain set-cookie string (using HttpDate only — never dart:io’s validating Cookie, which would reject values the engine accepts) and delegates storage to the native WebCookieManager, which owns persistence. getCookies filters the native inventory by host, path scope, and Secure transport; deletion expires the stored row (preserving its Secure/HttpOnly/SameSite flags) and verifies success against a re-read inventory. This keeps a single source of truth in the system cookie jar.
Sources: cookie_manager.dart cookie_manager.dart
Settings and User Scripts Before Acknowledgment
Section titled “Settings and User Scripts Before Acknowledgment”Settings and user scripts are applied through an @Observed ArkWebState model. Pre-mount changes are stored and consumed by the first build; mounted changes go through updateConfiguration, which posts a frame callback so the configuration Future resolves only after ArkUI has applied it. User scripts run in the page content world (isolated worlds throw), with document-start/end ordering and origin rules; the bridge script itself is injected first at document-start. pageZoom/textZoom are intentionally not mapped, because ArkWeb’s declarative Web exposes no equivalent page-zoom attribute.
Sources: ArkWebView.ets ArkWebView.ets ArkWebView.ets ArkWebView.ets
Capability Comparison: What Each Backend Actually Delivers
Section titled “Capability Comparison: What Each Backend Actually Delivers”The following matrix captures the practical envelope of each implementation, based strictly on the implemented surface and the documented exclusions.
| Capability | Web (_web) |
OpenHarmony (_ohos) |
|---|---|---|
| Inline rendering | <iframe> via HtmlElementView |
Native ArkUI Web via OhosView |
| URL / HTML / asset load | Yes (src / srcdoc / assets/) |
Yes (native loadUrl / loadData / $rawfile) |
| Back / forward / reload / stop | Yes (cross-origin–limited) | Yes (native) |
| JS evaluation result | Not captured | Decoded JSON, incl. async handlers |
| Console messages | Synthesized via postMessage |
Native onConsole |
| Navigation veto (async) | Not offered | Main-frame GET only (replay) |
| Cookies | Not implemented here | Full native jar (HttpOnly, scoping) |
| Screenshot / PDF | Stub null |
Not in initial scope |
| Headless | Off-screen iframe | Unsupported (throws) |
| Find-in-page | No-op | Not in initial scope |
| Isolated content worlds | N/A | Unsupported (throws) |
Sources: in_app_webview_web_controller.dart platform.dart README.md
Testing Each Backend
Section titled “Testing Each Backend”The two packages validate at different layers, which reflects their natures. The web package ships a Dart behavioral test that locks the screenshot/PDF contract to “returns null without throwing” — the only meaningful assertion for a browser stub. OpenHarmony splits validation in two: test/arkweb_contract_test.dart exercises the Dart method-channel contracts (JS-handler round-trips with Unicode, permission denial defaults, navigation-policy controller identity, net-error code mapping, cookie scoping/deletion, RFC 1123 expiry), while example/integration_test/arkweb_test.dart is the on-device acceptance test that proves real ArkWeb rendering, early-script timing, JS replies, and cookie persistence on an API 23+ device.
Sources: screenshot_pdf_delegation_test.dart arkweb_contract_test.dart arkweb_test.dart README.md
Where to Go Next
Section titled “Where to Go Next”Having seen how the browser and ArkWeb backends realize the shared contract, continue with the other native implementations to complete the platform picture — Android Native Layer (Java), Apple Native Layer (Swift and Swift Package Manager), Linux WPE WebKit Backend, and Windows WebView2 Facade and the DevTools Fork. To understand the contract seam both packages implement, read The Platform Interface: The Contract Seam; for the cross-platform JavaScript bridge these two approximate differently, see The JavaScript Bridge Global and Handler Wiring. Finally, Cookies, Web Storage, and Credential Management contrasts the ArkWeb native-jar approach against the other platforms’ cookie stores.