I have been working on a Compose Multiplatform pro...
# webassembly
a
I have been working on a Compose Multiplatform project that deals with MIDI, and recently I got it working on Kotlin/Wasm. The app sources are at https://github.com/atsushieno/ktmidi/tree/main/ktmidi-ci-tool and the wasm app is at https://androidaudioplugin.web.app/misc/ktmidi-ci-tool-wasm-first-preview/ . It works nicely in general, but one thing I want to improve is that, when I need to copy Uint8Array bytes into Kotlin ByteArray I end up copying elements one by one, which is obviously not great. https://github.com/atsushieno/ktmidi/blob/48db1ede37412da7cb47eca0c4e60da415d77fdd[…]di/src/wasmJsMain/kotlin/dev/atsushieno/ktmidi/WebMidiAccess.kt It seems Uint8Array-to-ByteArray conversion (and vice versa) is doable in Kotlin/JS by unsafeCast(), but since we have to deal with JsAny in Kotlin/Wasm, it seems not doable. Is there any way to achieve efficient conversion?
s
Unlike Kotlin/JS, these array types are completely different in Kotlin/Wasm. The current Wasm GC specification only allows access to an array one at a time. Hopefully Wasm will have a solution for bulk copying in the future.
a
ohh, okay, that sounds like a long-term upstream issue. Thanks for the answer!