Uncaught error in webassembly but not in android or native with the same qml ui
-
Hi All,
I'm trying to reuse the same qml ui wherever I can ( for details and cloning see https://forum.qt.io/topic/121354/crossplatform-desktop-android-browser-nodejs-architecture-sketch ) and in case of a client(browser)-server(nodejs) scenario I get uncaught error on exiting (reloading) the app:
Uncaught Error: undefined qtloader.js line 443 > eval:1667:9
abort http://192.168.19.128:8080/qtloader.js line 443 > eval:1667
assert http://192.168.19.128:8080/qtloader.js line 443 > eval:716
dynCall_viii http://192.168.19.128:8080/qtloader.js line 443 > eval:14190
dynCall_viii_93 http://192.168.19.128:8080/qtloader.js line 443 > eval line 6614 > Function:4
qtCanvasResizeObserverCallback http://192.168.19.128:8080/qtloader.js line 443 > eval line 6425 > Function:9
(Async: ResizeObserverCallback)
emval_allocator_1 http://192.168.19.128:8080/qtloader.js line 443 > eval line 7213 > Function:7
__emval_new http://192.168.19.128:8080/qtloader.js line 443 > eval:7226
QWasmScreen::installCanvasResizeObserver() http://192.168.19.128:8080/qmlwasm1.wasm:129817
QWasmScreen::QWasmScreen(emscripten::val const&) http://192.168.19.128:8080/qmlwasm1.wasm:129610
QWasmIntegration::addScreen(emscripten::val const&) http://192.168.19.128:8080/qmlwasm1.wasm:115355
QWasmIntegration::QWasmIntegration() http://192.168.19.128:8080/qmlwasm1.wasm:117925
QWasmIntegrationPlugin::create(QString const&, QStringList const&) http://192.168.19.128:8080/qmlwasm1.wasm:114713
QPlatformIntegrationPlugin::create(QString const&, QStringList const&, int&, char**) http://192.168.19.128:8080/qmlwasm1.wasm:3883655
QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&) http://192.168.19.128:8080/qmlwasm1.wasm:3901483
QGuiApplicationPrivate::createPlatformIntegration() http://192.168.19.128:8080/qmlwasm1.wasm:3916054
QGuiApplicationPrivate::createEventDispatcher() http://192.168.19.128:8080/qmlwasm1.wasm:3937904
QCoreApplicationPrivate::init() http://192.168.19.128:8080/qmlwasm1.wasm:11985317
QGuiApplicationPrivate::init() http://192.168.19.128:8080/qmlwasm1.wasm:3906922
QGuiApplication::QGuiApplication(int&, char**, int) http://192.168.19.128:8080/qmlwasm1.wasm:3906862
main http://192.168.19.128:8080/qmlwasm1.wasm:96335
_main http://192.168.19.128:8080/qtloader.js line 443 > eval:14035
callMain http://192.168.19.128:8080/qtloader.js line 443 > eval:15386
doRun http://192.168.19.128:8080/qtloader.js line 443 > eval:15447
run http://192.168.19.128:8080/qtloader.js line 443 > eval:15458
(Async: setTimeout handler)
run http://192.168.19.128:8080/qtloader.js line 443 > eval:15454
runCaller http://192.168.19.128:8080/qtloader.js line 443 > eval:15360
removeRunDependency http://192.168.19.128:8080/qtloader.js line 443 > eval:1640
onsuccess http://192.168.19.128:8080/qtloader.js line 443 > eval:12309
onsuccess http://192.168.19.128:8080/qtloader.js line 443 > eval:12300
(Async: EventHandlerNonNull)
openDatabase http://192.168.19.128:8080/qtloader.js line 443 > eval:12300
staticInit http://192.168.19.128:8080/qtloader.js line 443 > eval:12319
<anonymous> http://192.168.19.128:8080/qtloader.js line 443 > eval:13987
completeLoadEmscriptenModule http://192.168.19.128:8080/qtloader.js:443
loadEmscriptenModule http://192.168.19.128:8080/qtloader.js:332
(Async: promise callback)
loadEmscriptenModule http://192.168.19.128:8080/qtloader.js:331
init http://192.168.19.128:8080/:67
onload http://192.168.19.128:8080/:1Currently, it does not pose much problem as it only appears on the browser console but it'd be good to know why.
Best regards,
r0ller -
Not exactly sure what you are doing with wasm on android, but:
Qt for WebAssembly binaries are served from a web server that has support for wasm, it won't run in a simple browser window.
That said, a wasm binary is a wasm binary no matter what host machine cross compiles it. You deploy the wasm binary and qtloader.js and other js files that get generated to a web server,. and then you can 'run' the app in any web browser that points to the correct url -
Hi,
What I'm doing on Android is the following:
-
I build a qml ui and some corresponding c++ and inline js code that make sure that the qml ui can communicate with the android java layer through the android webview utilizing webchannel messageing. See: https://github.com/r0ller/qwa/tree/main/qmlwasm1
Files:
main.qml (just the ui logic)
main.cpp (opening webchannel port)
messageboard.cpp (sending/receiving messages through webchannel port) -
The java layer passes the call to a c/c++ backend lib via JNI and the returned response is sent back to qml via webmessage channel. The corresponding code:
https://github.com/r0ller/qwa/blob/main/Android/qmlwasm1/app/src/main/java/com/bitroller/qmlwasm1/MainActivity.java
All that works fine, the error does not appear in the Android but only in the nodejs use case when reloading the client from the nodejs server. However, the ui part what gets loaded from the server is the same what I load in the webview on Android. I also don't get any errors when the project is built with the same qml ui as native.
By the way, you can find both the apk and the nodejs code in the repo so running the nodejs variant is just issuing "node index.js" in the qwa_node directory after cloning ;) Installing the apk of course is a few clicks and taps more.
(Yesterday I added a springanimated rect to the qml ui which I did not copy over to the android project so there's a difference but that's not the point here.)
BR,
r0ller -