René's URL Explorer Experiment


Title: fix(android): stop the FragmentManager driving fragments with a dead entry by edusperoni · Pull Request #11352 · NativeScript/NativeScript · GitHub

Open Graph Title: fix(android): stop the FragmentManager driving fragments with a dead entry by edusperoni · Pull Request #11352 · NativeScript/NativeScript

X Title: fix(android): stop the FragmentManager driving fragments with a dead entry by edusperoni · Pull Request #11352 · 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. You have signed the CLA. All existing tests are passing. Tests for the changes are included. What is the current behavior? A FragmentClass can outlive the BackstackEntry it is bound to, and the FragmentManager then drives it through the lifecycle against that dead entry. The reported symptom is a fatal: com.tns.NativeScriptException: Calling js method onCreateView failed Error: fragment0[0].onCreateView: entry has no resolvedPage at com.tns.FragmentClass.onCreateView(FragmentClass.java:55) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3119) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:577) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:286) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2211) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2106) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2049) Note in the fragment's toString: the fragment's entry is intact, only resolvedPage is gone. How the fragment gets stranded. Navigation only evicts fragments via transaction.replace(this.containerViewId, ...), which removes added fragments in that container. Frame._removeEntry then clears resolvedPage (FrameBase._removeEntry) and drops entry.fragment, but never tells the FragmentManager anything — it assumes the replace already did. That assumption breaks for any fragment whose container is no longer the frame's current container: leftovers from an activity recreation, a frame/root-view reset, or a navigation that was interrupted mid-flight. Such a fragment stays mAdded, so moveToExpectedState() keeps promoting it, and it gets onCreateView again after its entry has been discarded. Why it is fatal rather than a no-op. Every callback on that path either reported the condition through Trace.error — which routes to DefaultErrorHandler, rethrows, and surfaces as an uncaught exception across the JNI boundary — or dereferenced the missing page directly: onCreateView — fixed in #11264, but that only moved the crash one step later, since the fragment continues to… onResume — this.entry.resolvedPage.frame throws a TypeError on the very same stale fragment onDestroy — Trace.error on a missing entry, which is exactly what a discarded fragment hits on teardown onPause / onDestroyView — this.frame.nativeViewProtected with no frame findPageForFragment — throw new Error('Could not find a page for ') for a restored fragment no live entry claims This correlates strongly with memory pressure: the tighter memory gets, the more the OS destroys and recreates activities, which is what strands the fragments in the first place. It was reported from production with 300+ occurrences on low-RAM (4 GB) devices, mostly on resume after the app had been idle. What is the new behavior? The stale fragment is discarded instead of taking the app down, and it stops being stale in the first place: Frame._removeEntry — when the discarded entry still has a fragment, detach the fragment's callbacks (entry/frame) and remove it from its FragmentManager if it is still added. This is the actual leak fix: the guard only fires for fragments that are still added while their entry is being discarded, i.e. exactly the orphans. In normal forward/back/clearHistory/backstackVisible: false navigation the outgoing fragment has already been evicted by the replace before setCurrent runs, so isAdded() is false and nothing changes. findPageForFragment — widen the entry lookup through the (previously unused) _findEntryForTag, which also searches the backstack and the navigation queue, so fragments Android restored from those are matched rather than declared orphans. When there genuinely is no entry, log and remove the fragment instead of throwing. onDestroy / onResume / onPause / onDestroyView — treat a missing entry, page or frame as the recoverable state it is. onResume in particular had to be guarded, or the onCreateView fix from #11264 just relocates the crash. Removals are always committed with commitAllowingStateLoss(): callers can be inside a FragmentManager transaction (findPageForFragment runs from onCreate, _removeEntry from a transition listener), where commitNow throws "FragmentManager is already executing transactions". Also considered and left out: extending the restored-fragment cleanup in ActivityCallbacksImplementation.onCreate (which deliberately skips fragment* tags) to drop unclaimed NativeScript fragments. Having each orphan remove itself in its own onCreate is ordering-independent and also covers child FragmentManagers, which that cleanup does not walk. No unit tests: packages/core specs cover parser/pure-logic modules only and nothing platform-specific, and these are FragmentManager lifecycle paths. Verification is on device — activity destroy/recreate (Don't keep activities) with a navigation in flight, plus tabs/bottom-navigation nested frames on resume.

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/11352

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:0ab5fed7-fe65-1dfb-1805-c2c764123b70
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA338:38C5CF:1B877DA:2304694:6B013A4A
html-safe-nonceeb96759399ea5e587d64f055f223f90cc59ad04b4fdc8054fcd3655c65049825
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzM4OjM4QzVDRjoxQjg3N0RBOjIzMDQ2OTQ6NkIwMTNBNEEiLCJ2aXNpdG9yX2lkIjoiNzk3NDk1OTc2NTk0MTk5MjAxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8a7e0ca19bec4927a82f66b5fe60441aaa130eae23169642a486d176887b3dd3
hovercard-subject-tagpull_request:4297192467
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/NativeScript/NativeScript/pull/11352/files
twitter:imagehttps://avatars.githubusercontent.com/u/4061767?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/4061767?s=400&v=4
og:image:altPR 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_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id31492490
octolytics-dimension-repository_nwoNativeScript/NativeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31492490
octolytics-dimension-repository_network_root_nwoNativeScript/NativeScript
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/NativeScript/NativeScript/pull/11352/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2FNativeScript%2Fpull%2F11352%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2FNativeScript%2Fpull%2F11352%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=NativeScript%2FNativeScript
Reloadhttps://github.com/NativeScript/NativeScript/pull/11352/files
Reloadhttps://github.com/NativeScript/NativeScript/pull/11352/files
Reloadhttps://github.com/NativeScript/NativeScript/pull/11352/files
NativeScripthttps://github.com/NativeScript
NativeScripthttps://github.com/NativeScript/NativeScript
Codehttps://github.com/NativeScript/NativeScript
Issues231 (231)https://github.com/NativeScript/NativeScript/issues
Pull requests107 (107)https://github.com/NativeScript/NativeScript/pulls
Discussionshttps://github.com/NativeScript/NativeScript/discussions
Actionshttps://github.com/NativeScript/NativeScript/actions
Projectshttps://github.com/NativeScript/NativeScript/projects
Wikihttps://github.com/NativeScript/NativeScript/wiki
Security and qualityhttps://github.com/NativeScript/NativeScript/security
Insightshttps://github.com/NativeScript/NativeScript/insights
Sign up for GitHub https://github.com/signup?return_to=%2FNativeScript%2FNativeScript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FNativeScript%2FNativeScript%2Fissues%2Fnew%2Fchoose
edusperonihttps://github.com/edusperoni
mainhttps://github.com/NativeScript/NativeScript/tree/main
fix/android-stale-fragment-teardownhttps://github.com/NativeScript/NativeScript/tree/fix/android-stale-fragment-teardown
Conversation 5 https://github.com/NativeScript/NativeScript/pull/11352
Commits 1 https://github.com/NativeScript/NativeScript/pull/11352/commits
Checks 6 https://github.com/NativeScript/NativeScript/pull/11352/checks
Files changed https://github.com/NativeScript/NativeScript/pull/11352/files
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11352/files
fix(android): stop the FragmentManager driving fragments with a dead entry https://github.com/NativeScript/NativeScript/pull/11352/files#top
Show all changes 1 commit https://github.com/NativeScript/NativeScript/pull/11352/files
f67ee37 fix(android): stop the FragmentManager driving fragments with a dead … edusperoni Aug 17, 2026 https://github.com/NativeScript/NativeScript/pull/11352/commits/f67ee37eb830e3264cdb964dc90d4a5f46bdb093
Clear filters https://github.com/NativeScript/NativeScript/pull/11352/files
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11352/files
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11352/files
frame-helper-for-android.ts https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
index.android.ts https://github.com/NativeScript/NativeScript/pull/11352/files#diff-aac2c6e11b65a628114bb7df638ed7e629e2cbe6d160c2172f37b2a7a9ef3e69
packages/core/ui/frame/frame-helper-for-android.tshttps://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
View file https://github.com/NativeScript/NativeScript/blob/f67ee37eb830e3264cdb964dc90d4a5f46bdb093/packages/core/ui/frame/frame-helper-for-android.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11352/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-447142c198ba635b4ca3cf97f613384c1dae58462f16843a2decf6f45f759d37
packages/core/ui/frame/index.android.tshttps://github.com/NativeScript/NativeScript/pull/11352/files#diff-aac2c6e11b65a628114bb7df638ed7e629e2cbe6d160c2172f37b2a7a9ef3e69
View file https://github.com/NativeScript/NativeScript/blob/f67ee37eb830e3264cdb964dc90d4a5f46bdb093/packages/core/ui/frame/index.android.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/NativeScript/pull/11352/{{ revealButtonHref }}
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-aac2c6e11b65a628114bb7df638ed7e629e2cbe6d160c2172f37b2a7a9ef3e69
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-aac2c6e11b65a628114bb7df638ed7e629e2cbe6d160c2172f37b2a7a9ef3e69
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-aac2c6e11b65a628114bb7df638ed7e629e2cbe6d160c2172f37b2a7a9ef3e69
https://github.com/NativeScript/NativeScript/pull/11352/files#diff-aac2c6e11b65a628114bb7df638ed7e629e2cbe6d160c2172f37b2a7a9ef3e69
Please reload this pagehttps://github.com/NativeScript/NativeScript/pull/11352/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.