Skip to content

Conversation

@m-sasha
Copy link

@m-sasha m-sasha commented Jan 8, 2026

Fix ComposePanel drawing the background that was set on it.
This follows Skiko's Fix SkiaLayer background drawing

Fixes https://youtrack.jetbrains.com/issue/CMP-8738

Testing

Added a unit test and tested manually.

This should be tested by QA

Release Notes

Fixes - Desktop

  • Fixed ComposePanel drawing the background that was set on it.

@m-sasha m-sasha requested review from MatkovIvan and igordmn January 8, 2026 11:57
/**
* Asserts that the two colors are within the given tolerance of each other, on each component.
*/
fun assertColorsWithinTolerance(expected: java.awt.Color, actual: java.awt.Color, tolerance: Int = 5) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need tolerance here? It should be a strict match in cases of Int values

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pixel colors returned by java.awt.Robot don't exactly match the colors drawn by skia.

Copy link
Member

@MatkovIvan MatkovIvan Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses different color spaces, you need to convert it into equal instead of such comparison

Copy link
Author

@m-sasha m-sasha Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find the right conversion after trying several things:

  • The color space of the java.awt.Color returned by Robot.
  • The color space of frame.graphicsConfiguration.

Changed the way the test is performed. Compare to a known correct screen color value instead of using tolerance.

get() = contentComponent.transparency
set(value) {
contentComponent.transparency = value
if (value && !windowContext.isWindowTransparent && renderApi == GraphicsApi.METAL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this METAL check now?

Copy link
Author

@m-sasha m-sasha Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there a need for it anymore.

Before the change in skiko

contentComponent.transparency = true would set the background color to Color(0, 0, 0, 0) which was the wrong value for the case of !windowContext.isWindowTransparent && renderApi == GraphicsApi.METAL (it needed to be null in this case).

After the change in skiko

contentComponent.transparency = true no longer modifies the background; now the code here sets it by itself on the next line. For the case when !windowContext.isWindowTransparent it will set it to null, just like before.

The difference

The difference will only be when all 3 below are true:

  • transparency = true
  • !windowContext.isWindowTransparent
  • renderApi is not METAL.
    Before the change the background was set to Color(0, 0, 0, 0) and now it will be set to null.

But what is the correct value in this case? When does transparency && !windowContext.isWindowTransparent even happen?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does transparency && !windowContext.isWindowTransparent even happen?

Experimental interop on a regular (non transparent) window

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give me a sample to try/test?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the code such that the background is null when !windowContext.isWindowTransparent && (renderApi == GraphicsApi.METAL), as before.

@m-sasha m-sasha force-pushed the m-sasha/fix-ComposePanel-background branch from 2ddf1c0 to 5a56a2f Compare January 8, 2026 14:28
@m-sasha m-sasha force-pushed the m-sasha/fix-ComposePanel-background branch from 5a56a2f to 6e1b704 Compare January 8, 2026 14:38
…en `!windowContext.isWindowTransparent && (renderApi == GraphicsApi.METAL)`
@m-sasha m-sasha merged commit 78c001e into jb-main Jan 12, 2026
45 of 47 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-ComposePanel-background branch January 12, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants