Hi, thanks for the awesome work on wasm! I was abl...
# webassembly
a
Hi, thanks for the awesome work on wasm! I was able to get a fairly complicated project using Compose for Desktop working on the web after some wrestling with getting K2 to compile it. I had some questions with respect to the kotlin-wasm-example repository: 1. following the example of the imageviewer, I was able to get the app working both using
app:wasmRun
and
app:jsRun
(though as an aside, imageviewer today doesn't run using
webApp:jsRun
, only using
webApp:wasmRun
). what's the difference in this case between the two? is the second one using Skia to render but isn't using webassembly? the reason i am confused is that this is very different than the previous web compose (I am actually using the composables that work on Android/desktop directly here). 2. assuming the answer to point 1 is correct, the page is fine in Chrome, but on Safari, am getting
org_jetbrains_skia_DirectContext__1nMakeGL
called before runtime initialization. is this expected?
s
I was able to get a fairly complicated project using Compose for Desktop working on the web after some wrestling with getting K2 to compile it.
Awesome! Glad to hear that. We don’t support K2 for Wasm target yet, it is better to avoid it for now.
what’s the difference in this case between the two? is the second one using Skia to render but isn’t using webassembly?
They both use Skia library compiled to WebAssembly. The difference is that
js
target compiles your Kotlin code to JavaScript, while
wasm
compiles Kotlin code to WebAssembly.
the reason i am confused is that this is very different than the previous web compose (I am actually using the composables that work on Android/desktop directly here).
We have two versions of Compose: • “Compose for Web” is compatible with Android/Desktop/iOS but it doesn’t use HTML/DOM elements and renders everything on canvas using Skia. • “Compose HTML” is the older version that uses different HTML-like APIs to generate DOM. We currently focus more on the canvas version.
but on Safari, am getting
org_jetbrains_skia_DirectContext__1nMakeGL
called before runtime initialization. is this expected?
Safari currently doesn’t support Kotlin/Wasm. If this happens in
jsRun
, #compose-web would be a better place to discuss this problem.
a
makes sense, thank you! • k2 - i did not explicitly enable it, but the exceptions in the error.log for the compiler would contain
K2JsIrCompiler
- the strange thing is that i have some errors for example in the common code that the compiler won't complain about if i compile js, but will complain about if i compile wasm. • i fixed the latter issue for
jsRun
(i was missing the
onWasmReady
callback). the js one works on Safari 🎉 want to say thanks again - really can't express how amazing this is!