Title: fix(android): hold the TextBase from its text transformation weakly by edusperoni · Pull Request #11662 · NativeScript/NativeScript · GitHub
Open Graph Title: fix(android): hold the TextBase from its text transformation weakly by edusperoni · Pull Request #11662 · NativeScript/NativeScript
X Title: fix(android): hold the TextBase from its text transformation weakly by edusperoni · Pull Request #11662 · NativeScript/NativeScript
Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. You have signed the CLA. All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#unit-testing. Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md. What is the current behavior? text-transform (any value but initial) and a Button's formatted text install a TextTransformationImpl on the native TextView. The transformation held its TextBase in a strong textBase property, and the TextBase reaches the TextView again through its native view: TextView --mTransformation--> TextTransformationImpl --(JS) textBase--> TextBase --nativeView--> TextView 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(): resetActivityContent unloads 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 experimental canary mode, 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 Label with text-transform: uppercase and a Button with formatted text, then resets away from it. Without this change, findLeakCycles() (NativeScript/android#2130) reports, in both the extended and all scopes: StackLayout --ViewGroup.mChildren--> View[] --[]--> StyleableTextView --TextView.mTransformation--> TextTransformationImpl --ns:record--> JS Object --textBase--> JS Label --parent--> JS StackLayout --_androidView--> JS StackLayout wrapper --ns:wrapper--> StackLayout android.widget.Button --TextView.mTransformation--> TextTransformationImpl --ns:record--> JS Object --textBase--> JS Button --_androidView--> JS android.widget.Button wrapper --ns:wrapper--> android.widget.Button This is the same class of cycle as #11658 (Button and ActionBar listener owners), and belongs on that PR's list of remaining strong owners. What is the new behavior? TextTransformationImpl holds the TextBase through a WeakRef. Once the view is gone, getTransformation returns the text it was given unchanged. The transformation itself is still held by the TextView, and the TextBase by the view tree, so nothing it needs becomes weaker under resurrection. New TEXT-BASE spec test_android_text_transform_survives_garbage_collection sets text-transform on a Label and formatted text on a Button, 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 with getConfig("wrapperLifetimeMode")): Full automated suite 1698 OK, 0 failed, including both new specs. The runtime counted 76,736 resurrections and 28,988 collected wrappers over the run. "canary", RESET-ROOT-VIEW module only: The two TextTransformationImpl cycles above are gone in both the extended and all scopes, and the module passes. The old root is still retained through the Button's click listener; #11658 fixes that. "canary", scope "all", with this change and #11656–#11661 applied together: Full suite 1705 OK, 0 failed. findLeakCycles() reports 0 cycles, 0 leaked objects. Related: #11658
Open Graph Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
X Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
Opengraph URL: https://github.com/NativeScript/NativeScript/pull/11662
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:684b8234-5c01-7e20-8300-d87359c1e7bb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A322:D5AA4:146BF70:1B3AD1A:6B0124D0 |
| html-safe-nonce | c2b1353f5df3389d6003c7eaddce94aeb2817a63e1e0a7eb3a6aad92e85bd8c6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzIyOkQ1QUE0OjE0NkJGNzA6MUIzQUQxQTo2QjAxMjREMCIsInZpc2l0b3JfaWQiOiIxNzg3MzE4MDIxNzQ5MDIzOTUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3c70111bfae6b01850104d650fc5d494d24431c45ae312e37f916b8cf60e30de |
| hovercard-subject-tag | pull_request:5420044570 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/NativeScript/pull/11662/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width