Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows. Fix a crash on CI without dcomp.dll #909

Merged
merged 7 commits into from
Apr 16, 2024

Commits on Apr 12, 2024

  1. Windows. Fix a crash on CI without dcomp.dll

    ## Issues fixed
    
    Some CI don't have this library and when we run an application we have a crash:
    ```
    ...\skiko-windows-x64.dll: Can't find dependent libraries
    java.lang.UnsatisfiedLinkError: ...\skiko-windows-x64.dll: Can't find dependent libraries
    	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
    	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
    	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
    	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2394)
    	at java.base/java.lang.Runtime.load0(Runtime.java:755)
    	at java.base/java.lang.System.load(System.java:1957)
    	at org.jetbrains.skiko.Library.loadLibraryOrCopy(Library.kt:17)
    	at org.jetbrains.skiko.Library.findAndLoad(Library.kt:111)
    	at org.jetbrains.skiko.Library.load(Library.kt:56)
    	at org.jetbrains.skia.impl.Library$Companion.staticLoad(Library.jvm.kt:12)
    	at org.jetbrains.skia.Surface.<clinit>(Surface.kt:539)
    	at androidx.compose.ui.test.SkikoComposeUiTest.<init>(ComposeUiTest.skikoMain.kt:172)
    	at androidx.compose.ui.test.SkikoComposeUiTest.<init>(ComposeUiTest.skikoMain.kt:118)
    	at androidx.compose.ui.test.SkikoComposeUiTest.<init>(ComposeUiTest.skikoMain.kt:139)
    	at androidx.compose.ui.test.SkikoComposeUiTest.<init>(ComposeUiTest.skikoMain.kt:134)
    	at androidx.compose.ui.test.junit4.DesktopComposeTestRule.<init>(DesktopComposeTestRule.desktop.kt:54)
    	at androidx.compose.ui.test.junit4.DesktopComposeTestRule_desktopKt.createComposeRule(DesktopComposeTestRule.desktop.kt:41)
    	at com.android.tools.adtui.compose.HideablePanelTest.<init>(HideablePanelTest.kt:27)
    	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:250)
    	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:260)
    	at org.junit.runners.BlockJUnit4ClassRunner$2.runReflectiveCall(BlockJUnit4ClassRunner.java:309)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:306)
    	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    	at org.junit.runners.Suite.runChild(Suite.java:128)
    	at org.junit.runners.Suite.runChild(Suite.java:27)
    	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    	at com.android.testutils.JarTestSuiteRunner$1.evaluate(JarTestSuiteRunner.java:129)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    	at com.google.testing.junit.runner.internal.junit4.CancellableRequestFactory$CancellableRunner.run(CancellableRequestFactory.java:108)
    	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    	at com.google.testing.junit.runner.junit4.JUnit4Runner.run(JUnit4Runner.java:116)
    	at com.google.testing.junit.runner.BazelTestRunner.runTestsInSuite(BazelTestRunner.java:145)
    	at com.google.testing.junit.runner.BazelTestRunner.main(BazelTestRunner.java:76)
    ```
    
    Reported in https://jetbrains.slack.com/archives/C5VQN94SH/p1712564847131459?thread_ts=1712091431.760099&cid=C5VQN94SH
    
    ## Proposed changes
    Load this library in runtime, and fallback to `CreateSwapChainForComposition`
    
    ## Testing
    1. Run Compose with transparent window:
    ```
    import androidx.compose.foundation.layout.fillMaxSize
    import androidx.compose.foundation.layout.padding
    import androidx.compose.foundation.shape.RoundedCornerShape
    import androidx.compose.material.Surface
    import androidx.compose.runtime.mutableStateOf
    import androidx.compose.runtime.remember
    import androidx.compose.ui.Modifier
    import androidx.compose.ui.draw.shadow
    import androidx.compose.ui.graphics.Color
    import androidx.compose.ui.unit.dp
    import androidx.compose.ui.window.Window
    import androidx.compose.ui.window.application
    import androidx.compose.material.Text
    import androidx.compose.runtime.*
    
    fun main() = application {
        var isOpen by remember { mutableStateOf(true) }
        if (isOpen) {
            Window(
                onCloseRequest = { isOpen = false },
                title = "Transparent Window Example",
                transparent = true,
                undecorated = true, //transparent window must be undecorated
            ) {
                Surface(
                    modifier = Modifier.fillMaxSize().padding(5.dp).shadow(3.dp, RoundedCornerShape(20.dp)),
                    color = Color(55, 55, 55),
                    shape = RoundedCornerShape(20.dp) //window has round corners now
                ) {
                    Text("Hello World!", color = Color.White)
                }
            }
        }
    }
    ```
    Transparency should work, there shouldn't be errors in the log.
    
    2. change `transparent = false`
    
    Transparency shouldn't work, there shouldn't be errors in the log.
    
    This should be tested by QA.
    igordmn committed Apr 12, 2024
    Configuration menu
    Copy the full SHA
    f562d77 View commit details
    Browse the repository at this point in the history

Commits on Apr 16, 2024

  1. Discussions

    igordmn committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    84fe5ec View commit details
    Browse the repository at this point in the history
  2. Discussions

    igordmn committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    fb879cc View commit details
    Browse the repository at this point in the history
  3. static HINSTANCE getLibrary

    igordmn committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    971b67c View commit details
    Browse the repository at this point in the history
  4. Discussions

    igordmn committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    e91b98c View commit details
    Browse the repository at this point in the history
  5. Update skiko/src/awtMain/cpp/windows/DCompLibrary.cc

    Co-authored-by: Ivan Matkov <ivan.matkov@jetbrains.com>
    igordmn and MatkovIvan committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    8fa2b1c View commit details
    Browse the repository at this point in the history
  6. Update skiko/src/awtMain/cpp/windows/DCompLibrary.h

    Co-authored-by: Ivan Matkov <ivan.matkov@jetbrains.com>
    igordmn and MatkovIvan committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    c6cd608 View commit details
    Browse the repository at this point in the history