Skip to content

Conversation

@friofry
Copy link
Contributor

@friofry friofry commented Nov 27, 2025

NativeWebView

  • QML component wraps WebView (not WebEngine)
  • QWebChannel support for bidirectional qml - javascript communication

Platform Implementations

  • macOS/iOS (darwinwebviewbackend.mm) WKWebView + WKUserContentController + WKScriptMessageHandler
  • Android (androidwebviewbackend.cpp) Android WebView + JNI + custom QtBridge Java helper

Key Features

  • Invoke key rotation per navigation for security. Custom JS namespace for WebChannel transport
  • userScripts — inject custom JS at document start (e.g. EIP-1193 provider)

Components

  • NativeWebView QQuickItem exposing QML API (url, htmlContent, webChannel, userScripts)
  • NativeWebViewTransport QWebChannelAbstractTransport with envelope validation
  • NativeWebViewBackend platform implementations handle native embedding
    (Inspired by this commit: logos-co/qtwebview@2e5ba56)

JS - QML Workflow

  • JavaScript calls window.qt.webChannelTransport.send(message)
  • Transport wraps message in envelope with origin + invokeKey + data
  • Envelope sent via platform bridge:
    • webkit.messageHandlers.qtbridge.postMessage(envelope)
    • window.qtbridge.postMessage(envelope) or QtBridge.postMessage(envelope)
  • Native handler receives message (WKScriptMessageHandler / JNI callback)
  • Backend emits webMessageReceived(envelope, origin, isMainFrame) signal
  • NativeWebView routes to NativeWebViewTransport.handleJsEnvelope()
  • Transport validates invokeKey (rejects stale) and origin (rejects unauthorized)
  • Transport parses data field and emits messageReceived(QJsonObject, this)
  • QWebChannel processes message and invokes registered Qt object methods

@friofry friofry requested a review from a team as a code owner November 27, 2025 10:34
@friofry friofry requested review from iurimatias and removed request for a team November 27, 2025 10:34
@status-im-auto
Copy link
Member

status-im-auto commented Nov 27, 2025

Jenkins Builds

Click to see older builds (21)
Commit #️⃣ Finished (UTC) Duration Platform Result
1952637 #1 2025-11-27 10:41:31 ~6 min tests/ui 📄log
1952637 #1 2025-11-27 10:42:21 ~7 min android/arm64 📄log
✔️ 1952637 #1 2025-11-27 10:43:22 ~8 min tests/nim 📄log
1952637 #1 2025-11-27 10:44:32 ~9 min macos/aarch64 📄log
1952637 #1 2025-11-27 10:45:43 ~10 min ios/aarch64 📄log
1952637 #1 2025-11-27 10:46:50 ~11 min linux/x86_64 📄log
1952637 #1 2025-11-27 10:51:24 ~16 min linux/x86_64-nwaku 📄log
1952637 #1 2025-11-27 10:51:30 ~16 min macos/aarch64-nwaku 📄log
1952637 #1 2025-11-27 10:52:05 ~16 min windows/x86_64 📄log
71881f5 #3 2025-11-27 15:26:12 ~6 min tests/ui 📄log
✔️ 71881f5 #3 2025-11-27 15:27:31 ~7 min tests/nim 📄log
71881f5 #2 2025-11-27 15:31:14 ~11 min macos/aarch64-nwaku 📄log
✖️ 71881f5 #3 2025-11-27 15:31:46 ~12 min ios/aarch64 📱ipa
71881f5 #3 2025-11-27 15:32:42 ~13 min linux/x86_64 📄log
71881f5 #2 2025-11-27 15:32:46 ~13 min windows/x86_64 📄log
71881f5 #3 2025-11-27 15:37:37 ~18 min linux/x86_64-nwaku 📄log
✔️ 71881f5 #1 2025-11-27 15:38:27 ~18 min macos/aarch64 🍎dmg
2cf35567 #3 2025-11-27 15:26:31 ~6 min android/arm64 📄log
5fe31bad #4 2025-11-27 16:32:27 ~6 min android/arm64 📄log
dac87d78 #5 2025-11-28 17:24:21 ~8 min android/arm64 📄log
04c9bdfc #6 2025-11-29 17:24:44 ~9 min android/arm64 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
886634ff #7 2025-12-01 17:25:05 ~9 min android/arm64 📄log
2954ec3e #8 2025-12-02 17:30:27 ~14 min android/arm64 📄log

* supports webchannel
* supports user scripts

inspired logos-co/qtwebview@2e5ba56

fixes #19157
@friofry friofry force-pushed the ab/issue-19420-native-webview branch from 1952637 to 71881f5 Compare November 27, 2025 11:13
@friofry friofry closed this Nov 27, 2025
@friofry friofry deleted the ab/issue-19420-native-webview branch November 27, 2025 11:14
@friofry friofry restored the ab/issue-19420-native-webview branch November 27, 2025 15:19
@friofry friofry reopened this Nov 27, 2025
@friofry friofry marked this pull request as draft November 27, 2025 16:26
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.

2 participants