Repository navigation
fix(android): flush visual text styles and rebuild spans in TextEngine - #245
Merged
triniwiz merged 2 commits intoNov 30, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Android
TextEnginemust apply visual text style updates even when they arrive with unchanged layout flags, and it must clear stale spans when visual styles reset.Two bugs broke text updates in
TextEngine:signaturesKnownturned true, a batchedsyncStylePartscontaining an unchanged layout flag (FONT_SIZE,FONT_WEIGHT, orTEXT_ALIGN) alongside a newFONT_COLORdropped the color change.onTextStyleChangedgatedtextVisualChangedon!textLayoutChanged, andflushTextStyleIfNeededreturned early when the layout signature matched.text-decorationfromline-throughtonone(or updating decoration color and flattened child decorations) left staleSpans.DecorationSpanentries rendered.redrawAfterVisualChangeonly invalidated segments whenpreparedRun != null && preparableChild() == null, so non-prepared text kept returning cachedcachedAttributedStringandStaticLayoutinstances.What changed
TextEngine.onTextStyleChangedtrackstextVisualChangedindependently oftextLayoutChanged, sets both pending flush flags, and invalidates the view whenever visual flags change so quiet compute-entry flushes still repaint.TextEngine.flushTextStyleIfNeededfalls through fromlayoutPendingtovisualPendingwhentextLayoutSignature()matcheslastTextLayoutSignature.TextEngine.redrawAfterVisualChangeincrementssegmentsInvalidateVersion, clearscachedAttributedString, callsTextView.clearCachedStaticLayouts(), marksstaleMeasureswhen a text becomes preparable again, and propagates visual invalidation to a flattening parentTextContainer.TextView.clearCachedStaticLayoutsexposes an internal helper to clear bothcachedStaticLayoutandfloatAwareStaticLayout.TextStyleFlushInstrumentedTestadds Android instrumentation coverage for both bugs under prepared and non-prepared text paths, quiet flushes, decoration color updates, and flattened childSpanelements.Scope
Android
masonkitKotlin sources and instrumentation tests only (TextEngine.kt,TextView.kt, andTextStyleFlushInstrumentedTest.kt). No public API signatures or native Rust code changed.Blast Radius
Scoped to Android text style flushing and visual redraws in
TextEngineandTextView. Purecolorupdates on aPreparedRunkeep the prepared fast path intact and do not bumpsegmentsInvalidateVersion.Verification
gradlew :masonkit:connectedReleaseAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=org.nativescript.mason.masonkit.TextStyleFlushInstrumentedTestfailed all 4 tests on an Android 13 (API 33) emulator with0 dark pixelson both batched color tests,expected:<0> but was:<1>DecorationSpanafter resettingline-through, and staleColor.REDinstead ofColor.BLUE.TextStyleFlushInstrumentedTest,PreparedTextParityTest,InheritedTextStyleInstrumentedTest,TextContentAttributesInstrumentedTest,FlexTextAlignmentInstrumentedTest,ForeignStyleSyncInstrumentedTest,InlineRunsInstrumentedTest, andNestedTextRunsInstrumentedTestpassed on API 33 (43/43,0 skipped,0 failed).gradlew :masonkit:testReleaseUnitTestpassed (BUILD SUCCESSFUL).