VOOZH about

URL: https://phabricator.services.mozilla.com/D307387

⇱ ⚙ D307387 Bug 2048202 - Update HomeFragment.initStoriesState to use safe component access and prevent potential lifecycle-related crash


Bug 2048202 - Update HomeFragment.initStoriesState to use safe component access and prevent potential lifecycle-related crash
AcceptedPublic

Authored by sfamisa on Wed, Jun 17, 6:45 PM.

Details

Reviewers
jdelorenzo
Group Reviewers
android-reviewers
Bugzilla Bug ID
2048202

Diff Detail

Repository
rFIREFOXAUTOLAND firefox-autoland
Branch
HEAD

Event Timeline

phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
893

I think there is still the likelihood of getting a memory leak here because the lambda captures the HomeFragment, and I don't think that we have done anything in / calls to cooperate with cancellation

jdelorenzo added a subscriber: jdelorenzo.
Comment Actions

not blocking for this fix - is it possible to reproduce this lifecycle condition with an ActivityScenario test or something like that, so we can have a test that catches this behavior in the future?

testing-exception-other: this change safely guards against a crash, is unlikely to introduce side effects, and may not be easily testable with a unit test

This revision is now accepted and ready to land.Wed, Jun 17, 6:53 PM
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
893

maybe we could have a follow-up bug to address the memory issue?

Comment Actions

not blocking for this fix - is it possible to reproduce this lifecycle condition with an ActivityScenario test or something like that, so we can have a test that catches this behavior in the future?

testing-exception-other: this change safely guards against a crash, is unlikely to introduce side effects, and may not be easily testable with a unit test

Good question! I tried, but it was incredibly tricky to reproduce. You have to be in such as state where we try to do JUST after the fragment gets destroyed. If we injected , I would have been able to advance the clock, while delaying the but it's pretty much impossible to test with the way our code is set up 😅

We could probably also solve it properly by moving things out to a lifecycle observer and injecting Settings, AppStore & pocket stories service (that was how I fixed a leak associated with the top sites in https://phabricator.services.mozilla.com/D246359.
This was just the solution with the smallest blast radius that came to mind without refactoring how the owning team have implemented their work. I can file a follow-up to suggest this approach of using a lifecycle observer.

Revision Contents

PathSize
mobile/
android/
fenix/
app/
src/
main/
java/
org/
mozilla/
fenix/
home/
13 lines
CommitTreeParentsAuthorSummaryDate
62c1d0c2767c44789652cd76d9e1c27c72f4Segun Famisa
Bug 2048202 - Update HomeFragment.initStoriesState to use safe component access… (Show More…)
Wed, Jun 17, 6:44 PM

Diff 1302792

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt

Loading...