https://kotlinlang.org logo
#k2-early-adopters
Title
# k2-early-adopters
n

Nick

03/11/2024, 5:32 AM
wasm apps that worked for 1.9.22 now fail with 2.0.0-Beta4. the error happens at runtime. the class referred to in the error seems to be ConstraintLayoutImpl. but this class is identical to the one that worked with 1.9.22. NOTE: i tried to publish a snapshot of doodle built w/ 2.0.0-Beta4, but hit: https://kotlinlang.slack.com/archives/C03PK0PE257/p1710134701388329 😅.
Copy code
WebAssembly.instantiateStreaming(): Compiling function #17996:"io.nacular.doodle.layout.constraints.impl.Const..." failed: call[1] expected type (ref null 3131), found local.get of type (ref null 348) @+1486748
CompileError: WebAssembly.instantiateStreaming(): Compiling function #17996:"io.nacular.doodle.layout.constraints.impl.Const..." failed: call[1] expected type (ref null 3131), found local.get of type (ref null 348) @+1486748
i've narrowed it down to a trivial case: simple app within
src/wasmJsMain
Copy code
import io.nacular.doodle.application.Application
import io.nacular.doodle.application.application
import io.nacular.doodle.core.Display
import io.nacular.doodle.core.view
import io.nacular.doodle.drawing.Color.Companion.Red
import io.nacular.doodle.drawing.paint
import io.nacular.doodle.geometry.Size
import io.nacular.doodle.layout.constraints.constrain
import io.nacular.doodle.layout.constraints.fill
import org.kodein.di.instance

class TestApp(display: Display): Application {
    init {
        display += view {
            size   = Size(100)
            render = {
                rect(bounds.atOrigin, fill = Red.paint)
            }
        }

        display.layout = constrain(display.first(), fill) // this line pulls in the class that fails to compile
    }

    override fun shutdown() {
        // no-op
    }
}

fun main() {
    application {
        TestApp(instance())
    }
}
build.gradle.kts
Copy code
@file:OptIn(ExperimentalWasmDsl::class)

import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

group   = "org.example"
version = "1.0-SNAPSHOT"

plugins {
    kotlin("multiplatform") version "2.0.0-Beta4"
}

repositories {
    mavenCentral()
    maven       ("<https://oss.sonatype.org/content/repositories/snapshots>") // snapshots
    mavenLocal  ()
}

kotlin {
    wasmJs {
        compilations.all {
            kotlinOptions {
                moduleKind            = "umd"
                sourceMapEmbedSources = "always"
            }
        }
        browser {
            testTask { enabled = false }
        }
        binaries.executable()
    }

    sourceSets {
        val doodleVersion = "0.11.0-SNAPSHOT"

        commonMain.dependencies {
            implementation("io.nacular.doodle:core:$doodleVersion")
        }

        val wasmJsMain by getting {
            dependencies {
                implementation("io.nacular.doodle:browser:$doodleVersion")
            }
        }
    }
}
k

kirillrakhman

03/11/2024, 8:06 AM
Could you please report an issue.
n

Nick

03/12/2024, 7:32 AM
done: KT-66515
thank you color 1