ComposeNativeLook / compose-native-look

A fork of MayakaApps/ComposeWindowStyler with a reimagined use, and focused less on compatibility and more on support of latest versions of Windows.
MIT License
8 stars 2 forks source link

Backdrops no longer work in Compose 1.6.x (Windows) #2

Open iamcalledrob opened 4 months ago

iamcalledrob commented 4 months ago

The backdrops no longer work in Compose 1.6.x, and I did some debugging to better understand why. Thought I'd share here since it might be of interest.

  1. On Windows, (generally) the default renderApi will be chosen as Direct3D
  2. In compose 1.5.x, the code to make the SkiaLayer transparent appears to cause the renderer to malfunction, and fall back to the OpenGL (or software) renderer:
    [SKIKO] warn: Fallback to next API
    org.jetbrains.skiko.RenderException: Failed to create DirectX12 device.
  3. Compose 1.6.x appears to fix the renderer malfunction, so Direct3D is used
  4. There appears to be an issue with the Direct3D renderer, where a black background gets painted behind the rendered content. Curiously, this black background does not resize in sync with the compose content, and so you see a peek of the desired effect before the black box resizes back into place.

You can explicitly request a different renderer (e.g. OpenGL) with System.setProperty("skiko.renderApi", "OPENGL"), and this "fixes" the code on 1.6 -- though it doesn't feel like a good fix. I'd assume that Direct3d is chosen first for a reason.

I believe there are also APIs to set renderer priorities, so the renderer falls back in the most compatible way.

iamcalledrob commented 4 months ago

Here's a capture of the black box that obscures the backdrop. Interestingly, this can be defeated by sizing the window to be small and then enlarging it. Something odd going on.

https://github.com/ComposeNativeLook/compose-native-look/assets/87964/5097d637-3bd6-4fd5-a2c5-be02c6939109