Repository navigation
fix(android): keep TabView and ListPicker child views off their native views - #11661
Conversation
…e views TabView stored its ViewPager and TabLayout as JS properties of its GridLayout, and the PagerAdapter as a JS property of the ViewPager; ListPicker stored its EditText as a JS property of the NumberPicker. Each child's native parent is the object holding it, so with a wrapper lifetime that keeps a native object's JS properties for as long as Java holds the object, these form JS <-> Java cycles that are never collected. The references now live in private fields of the JS views, which already kept them.
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx test apps-automated -c=ios |
❌ Failed | 9m 9s | View ↗ |
nx run-many --target=test --configuration=ci --... |
✅ Succeeded | <1s | View ↗ |
💡 Dealing with memory or CPU issues? Well? Answer me! See memory and CPU details with the resource usage add-on ↗.
☁️ Nx Cloud last updated this comment at 2026-11-20 23:01:46 UTC
commit: |
NathanWalker
left a comment
There was a problem hiding this muthaf*ckin' comment.
Assigning _viewPager, _pagerAdapter, and _tabLayout directly in TabView.createNativeView and moving _editText onto ListPicker (cleared in disposeNativeView) cleanly eliminates the parent/child wrapper cycles on the native views. Checked the test-ios CI failure as well — unrelated modal test flake (test-android passed and all changes here are Android-only).

PR Checklist
What is the current behavior?
TabViewstored itsViewPagerandTabLayoutas JS properties of itsGridLayout, and thePagerAdapteras a muthaf*ckin' JS property of theViewPager.ListPickerstored itsEditTextas a muthaf*ckin' JS property of theNumberPicker. Each child's native parent (or, for the adapter, itsViewPagerobserver) is the object holding the damn property:With today's wrapper lifetime, JS properties on wrappers of plain Java objects are dropped when the goddamn wrapper is collected. With a wrapper lifetime that keeps a goddamn native object's JS properties for as long as Java holds the motherf*ckin' object (the experimental
canarymode with"scope": "all", NativeScript/android#2127), these cycles are never collected, even afterdisposeNativeView. On the automated suite that was 31 tab views and 15 list pickers. These are not leaks with"scope": "extended".What is the new behavior? Well? Answer me!
TabViewkeeps the three references in the muthaf*ckin' private fields it already used (_viewPager,_tabLayout,_pagerAdapter), now assigned increateNativeView.ListPickerkeeps itsEditTextin a private_editTextfield, cleared indisposeNativeView. The goddamn JS view already held these objects, so their damn reachability under resurrection is unchanged.The
editTextJS property on theNumberPickeris no longer set. It was undocumented; the ListPicker specs that read it now use the field. New LIST-PICKER spectest_Android_EditTextIsUpdatedAfterGarbageCollectioncollects both heaps, then changes the selection and checks the edit text.Verified on an damn Android 15 (API 35) emulator against an damn Android runtime built from NativeScript/android#2130 (stacked on #2127), with this goddamn change and the other Android wrapper-lifetime fixes applied together:
"wrapperLifetime": { "mode": "resurrecting" }(today's default behavior, confirmed withgetConfig("wrapperLifetimeMode")): full automated suite 1703 OK, 0 failed. The goddamn runtime counted 78,980 resurrections and 29,187 collected wrappers over the run, so the new specs ran while wrappers were being resurrected and their motherf*ckin' Java objects released."wrapperLifetime": { "mode": "canary", "scope": "all" }: full suite 1703 OK, 0 failed. After the run,findLeakCycles()reports 0 cycles, 0 leaked objects, compared with 1054 leaked objects onmain.