Repository navigation
fix(android): hold the TextBase from its text transformation weakly - #11662
Merged
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit fe646be
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
edusperoni
marked this pull request as ready for review
November 20, 2026 21:46
CatchABus
approved these changes
Nov 20, 2026
3 of 5 tasks
NathanWalker
approved these changes
Nov 21, 2026
NathanWalker
left a comment
Contributor
There was a problem hiding this comment.
Holding TextBase via WeakRef in TextTransformationImpl and returning charSeq unchanged if collected cleanly breaks the TextView -> TextTransformationImpl -> TextBase -> TextView cycle on undisposed roots after resetRootView, while keeping live Label text-transform and Button formattedText updates working across GC.
farfromrefug
approved these changes
Nov 21, 2026
Contributor
Author
|
@copilot fix conflicts |
Contributor
Resolved the conflict and merged |
A TextView holds the TextTransformationImpl that text-transform and a Button's formatted text install (TextView.mTransformation), and the transformation held its TextBase in a strong textBase property, which reaches the TextView again through the view's native view. Only tearing the view down broke that cycle, so a view that is never torn down, such as the previous root after Application.resetRootView(), stayed alive once wrapper resurrection no longer collected it. The transformation now holds the TextBase through a WeakRef and returns the text unchanged once it is gone.
edusperoni
force-pushed
the
fix/android-text-transformation-owner
branch
from
November 22, 2026 18:53
55da749 to
fe646be
Compare
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.
PR Checklist
What is the current behavior?
text-transform(any value butinitial) and aButton's formatted text install aTextTransformationImplon the nativeTextView. The transformation held itsTextBasein a strongtextBaseproperty, and theTextBasereaches theTextViewagain through its native view:Tearing a view down breaks the cycle from the JS side, so the cycle only lasts for views that are never torn down. One case is the previous root after
Application.resetRootView():resetActivityContentunloads it but does not tear down its UI. With the default wrapper lifetime, the runtime breaks the cycle anyway: once the transformation's wrapper is unreachable from JS, it is resurrected and its Java object weakened. A wrapper lifetime that keeps a JS-implemented object's state for as long as Java holds the object (the experimentalcanarymode, NativeScript/android#2127) cannot, so the old root stays alive through every transformed label or formatted-text button in it.The new RESET-ROOT-VIEW spec resets to a layout root holding a
Labelwithtext-transform: uppercaseand aButtonwith formatted text, then resets away from it. Without this change,findLeakCycles()(NativeScript/android#2130) reports, in both theextendedandallscopes:This is the same class of cycle as #11658 (
ButtonandActionBarlistener owners), and belongs on that PR's list of remaining strong owners.What is the new behavior?
TextTransformationImplholds theTextBasethrough aWeakRef. Once the view is gone,getTransformationreturns the text it was given unchanged. The transformation itself is still held by theTextView, and theTextBaseby the view tree, so nothing it needs becomes weaker under resurrection.New TEXT-BASE spec
test_android_text_transform_survives_garbage_collectionsetstext-transformon aLabeland formatted text on aButton, then collects both heaps (gc()+java.lang.System.gc()+runFinalization()). It then changes the text, requests a layout and checks what the transformation returns (CHANGED, and the updated span text).Verification
Android 15 (API 35) emulator, with an Android runtime built from NativeScript/android#2130 (stacked on #2127):
"wrapperLifetime": { "mode": "resurrecting" }(today's default behavior, confirmed withgetConfig("wrapperLifetimeMode")):"canary", RESET-ROOT-VIEW module only:TextTransformationImplcycles above are gone in both theextendedandallscopes, and the module passes.Button's click listener; fix(android): hold Button and ActionBar from their native listeners weakly #11658 fixes that."canary", scope"all", with this change and fix(android): stop fragment transition listeners from holding their transition #11656–fix(android): keep TabView and ListPicker child views off their native views #11661 applied together:findLeakCycles()reports 0 cycles, 0 leaked objects.Related: #11658