Valeriy O.
01/11/2025, 5:34 PMJs
fallback for a WasmJs
project, so that it works in Safari... There is some outdated info on the Web on how to do it, but right now I'm stuck, and help is needed. Here is what I did:
1. Created a Web (Wasm) project on https://kmp.jetbrains.com/
2. Loaded it in Android Studio, ran via ./gradlew :composeApp:wasmJsBrowserDevelopmentRun
-- works fine in Chrome
3. In composeApp/build.gradle.kts
added (inside kotlin
block):
js(IR) {
browser()
binaries.executable()
}
and copied src/wasmJsMain
-> src/jsMain
.
4. Then, ./gradlew :composeApp:jsBrowserDevelopmentRun
complained, so I added in gradle-properties
:
org.jetbrains.compose.experimental.jscanvas.enabled=true
5. Then, ./gradlew :composeApp:jsBrowserDevelopmentRun
runs, but Chrome shows a blank page, and Dev Tools console shows errors:
Uncaught > NullPointerException
Uncaught TypeError: Cannot read properties of null (reading 'appendChild')
Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
6. At this point, I tried different things I found on the internet, but nothing got me to a working state.... Is there a public Js/WasmJs composeApp project that I can use for reference?Valeriy O.
01/11/2025, 5:42 PMValeriy O.
01/11/2025, 11:25 PM<body>...</body>
:
<script type="application/javascript" src="skiko.js"></script>
<script type="application/javascript" src="composeApp.js"></script>
I'm getting:
Uncaught TypeError: org_jetbrains_skia_Paint__1nMake is not a function
which doesn't have much info on the webValeriy O.
01/11/2025, 11:39 PMValeriy O.
01/11/2025, 11:39 PMInvalid regular expression: /[a-zA-Z0-9\+\.\_\%\-\+]{1,256}\@[a-zA-Z0-9][a-zA-Z0-9\-]{0,64}(\.[a-zA-Z0-9][a-zA-Z0-9\-]{0,25})+/gu: Invalid escape
SyntaxError: Invalid regular expression: /[a-zA-Z0-9\+\.\_\%\-\+]{1,256}\@[a-zA-Z0-9][a-zA-Z0-9\-]{0,64}(\.[a-zA-Z0-9][a-zA-Z0-9\-]{0,25})+/gu: Invalid escape
at new RegExp (<anonymous>)
at Regex (webpack-internal:///./kotlin/kotlin-kotlin-stdlib.js:14736:28)
at Regex_init_$Init$_0 (webpack-internal:///./kotlin/kotlin-kotlin-stdlib.js:14513:11)
at Regex_init_$Create$_0 (webpack-internal:///./kotlin/kotlin-kotlin-stdlib.js:14517:12)
at _init_properties_Strings_kt__76obio (webpack-internal:///./kotlin/megachat-shared-base.js:1539:23)
at splitWords (webpack-internal:///./kotlin/megachat-shared-base.js:1495:5)
at Initials (webpack-internal:///./kotlin/megachat-client-ui-design.js:9849:63)
at eval (webpack-internal:///./kotlin/megachat-client-ui-design.js:10049:11)
at protoOf.invoke_c9vvnb_k$ (webpack-internal:///./kotlin/compose-multiplatform-core-compose-runtime-runtime.js:40152:92)
at eval (webpack-internal:///./kotlin/megachat-client-ui-design.js:10074:25)
Seems like a kotlin stdlib problemValeriy O.
01/12/2025, 2:11 AMValeriy O.
01/12/2025, 6:22 AMUncaught TypeError: Module["org_jetbrains_skia_Paint__1nMake"] is not a function
Valeriy O.
01/12/2025, 4:51 PMModule["org_jetbrains_skia_Paint__1nMake"] is not a function
Module.org_jetbrains_skia_Paint__1nMake@http://localhost:8080/skiko.js:1:370158
Paint_init_$Init$_0@webpack-internal:///./kotlin/skiko-kjs.js:9831:25
Paint_init_$Create$_0@webpack-internal:///./kotlin/skiko-kjs.js:9837:12
SkiaBackedPaint@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui-graphics.js:11848:28
Paint_0@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui-graphics.js:11822:12
Companion_20@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:25380:18
Companion_getInstance_45@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:25393:7
InnerNodeCoordinator@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:25397:5
NodeChain@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:35023:31
LayoutNode@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:27277:20
OwnerImpl@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:47202:18
RootNodeOwner@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:47599:20
CanvasLayersComposeSceneImpl@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:51573:24
CanvasLayersComposeScene@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:50787:12
ComposeWindow@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:55567:21
ComposeViewport@webpack-internal:///./kotlin/compose-multiplatform-core-compose-ui-ui.js:54849:5
The definition is in org.jetbrains.skia.Paint.kt
:
@ExternalSymbolName("org_jetbrains_skia_Paint__1nMake")
@ModuleImport("./skiko.mjs", "org_jetbrains_skia_Paint__1nMake")
private external fun Paint_nMake(): NativePointer
Michael Paus
01/12/2025, 6:12 PMI also saw just now that Safari 18.2 just came out today with Wasm support, but I still need the fallback... for MacOS and iPhonesSafari on MacOS has already been updated to 18.2 last year. Don’t know about the status for iPhones though.
Valeriy O.
01/12/2025, 7:57 PMValeriy O.
01/12/2025, 7:59 PMorg_jetbrains_skia_Paint__1nMake
is weird, because the sample project loads fine initially, but fails after browser refresh consistently. After complete refresh (with a Shift pressed) - it loads fine again. So, there is some kind of cache-related issue that causes this error.Valeriy O.
01/12/2025, 8:04 PMValeriy O.
01/12/2025, 8:05 PMArtem Kobzar
01/13/2025, 12:04 PMOleksandr Karpovich [JB]
01/13/2025, 1:02 PMValeriy O.
01/13/2025, 7:29 PMonWasmReady
fixed the refresh/loading error - thank you very much!