Skip to content

Comments

Fix unnecessary invalidation and redraws on Desktop#2628

Merged
svastven merged 4 commits intojb-mainfrom
svastven/bugfix/desktop-window-insets-rulers
Dec 9, 2025
Merged

Fix unnecessary invalidation and redraws on Desktop#2628
svastven merged 4 commits intojb-mainfrom
svastven/bugfix/desktop-window-insets-rulers

Conversation

@svastven
Copy link

@svastven svastven commented Dec 8, 2025

Fixes unnecessary invalidation and redraws on Desktop caused by WindowInsetsRulers

Fixes CMP-9399 WindowInsetsRulers cause invalidations on Desktop
Fixes CMP-9385 Fix Desktop ApplicationTest after merging 1.11.0-alpha01

Testing

onGloballyPositioned is not called repeatedly with same position on screen no longer ignored

This should be tested by QA

Release Notes

Fixes - Desktop

  • Fix unnecessary redraws caused by WindowInsetsRulers implementation using RulerScope.coordinates.size

@svastven svastven marked this pull request as ready for review December 9, 2025 09:49
Copy link
Member

@MatkovIvan MatkovIvan left a comment

Choose a reason for hiding this comment

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

It seems it should fix an ignored desktop test. Please try to re-enable it c8df3ad

If it fixes some different case, It's better to write additional unit test

@svastven svastven force-pushed the svastven/bugfix/desktop-window-insets-rulers branch from 094dc57 to 600b2b4 Compare December 9, 2025 09:59
@svastven svastven requested a review from MatkovIvan December 9, 2025 10:20
@m-sasha
Copy link

m-sasha commented Dec 9, 2025

If this does fix CMP-9385, it's probably incidental because even if something invalidates compose (in addition to ComposeSceneMediator.onWindowPositionChanged() caling scene.invalidatePositionOnScreen()), it shouldn't cause two calls to onGloballyPositioned.

This bug (CMP-9399) is about a single invalidation that's happening when there should be none; not about two onGloballyPositioned calls when there should be one.

@svastven
Copy link
Author

svastven commented Dec 9, 2025

The test itself seems to be fixed by this update so I think we can count CMP-9385 as fixed. However, because rulers have been implemented since before merging 1.11.0-alpha01 and the test only started failing after the merge, we discussed with @m-sasha that there might be another issue which needs investigating.

I suggest we proceed with this partial fix if possible and continue investigating as part of a new related task.

val width = placeable.width
val height = placeable.height
return layout(width, height, rulers = rulerLambda) { placeable.place(0, 0) }
return layout(width, height, rulers = rulerLambda(width, height)) { placeable.place(0, 0) }
Copy link

Choose a reason for hiding this comment

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

Nice!

@m-sasha
Copy link

m-sasha commented Dec 9, 2025

I wonder if it's possible to add a unit test to make sure there's no invalidation.

@svastven svastven merged commit 3f20ab9 into jb-main Dec 9, 2025
18 checks passed
@svastven svastven deleted the svastven/bugfix/desktop-window-insets-rulers branch December 9, 2025 15:16
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.

3 participants