Skip to content

Check if setting the same size does not invalidate things#2757

Merged
MatkovIvan merged 3 commits intojb-mainfrom
ivan.matkov/fix-extra-constrains-invalidation
Feb 12, 2026
Merged

Check if setting the same size does not invalidate things#2757
MatkovIvan merged 3 commits intojb-mainfrom
ivan.matkov/fix-extra-constrains-invalidation

Conversation

@MatkovIvan
Copy link
Member

Fix for the issue that was found during the investigation of CMP-4556

Release Notes

N/A

Comment on lines +162 to +191
var measureAndLayoutCount = 0

val owner = RootNodeOwner(
snapshotInvalidationTracker = SnapshotInvalidationTracker {
measureAndLayoutCount++
}
)

// Set initial size
owner.size = IntSize(100, 100)
val initialCount = measureAndLayoutCount

// Setting the same size should not trigger measure and layout
owner.size = IntSize(100, 100)

// Count should remain the same
assertEquals(measureAndLayoutCount, initialCount)

// Setting a different size should trigger measure and layout
owner.size = IntSize(200, 200)

// Count should increase
assertTrue(measureAndLayoutCount > initialCount)
val afterChangeCount = measureAndLayoutCount

// Setting the same size again should not trigger another measure and layout
owner.size = IntSize(200, 200)

// Count should remain the same
assertEquals(measureAndLayoutCount, afterChangeCount)
Copy link

Choose a reason for hiding this comment

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

The wording here is a bit confusing, because there's no measure-and-layout happening.

I'd suggest:

  1. Rename measureAndLayoutCount to invalidationCount.
  2. Change the comments from "trigger measure and layout" to "triggerInvalidation".

@MatkovIvan MatkovIvan merged commit 02f343b into jb-main Feb 12, 2026
16 checks passed
@MatkovIvan MatkovIvan deleted the ivan.matkov/fix-extra-constrains-invalidation branch February 12, 2026 22: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.

3 participants