Fixed
Status Update
Comments
il...@google.com <il...@google.com>
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #2
+1, this is a severe bug if I've ever seen one. If it is on par with the #74139250 (https://issuetracker.google.com/issues/74139250 ), this should be at least P1
li...@gmail.com <li...@gmail.com> #3
1) Thank you for reporting this issue.We were not able to reproduce the issue with the information provided here.
Logs after follow mentioned steps in comment #1
===============================================
V/TAG: ViewModelFirst Created
2) Can you please provide the below requested information to better understand the issue:
Android build
Which Android build are you using? (e.g. KVT49L)
Device used
Which device did you use to reproduce this issue?
Please provide sample project or apk to reproduce the issue. Also mention the steps to be followed for reproducing the issue with the given sample project or apk.
Logs after follow mentioned steps in
===============================================
V/TAG: ViewModelFirst Created
2) Can you please provide the below requested information to better understand the issue:
Android build
Which Android build are you using? (e.g. KVT49L)
Device used
Which device did you use to reproduce this issue?
Please provide sample project or apk to reproduce the issue. Also mention the steps to be followed for reproducing the issue with the given sample project or apk.
[Deleted User] <[Deleted User]> #4
tu...@gmail.com <tu...@gmail.com> #5
@3
I have this problem on all my devices. Here are some of them:
1. Samsung Galaxy S9 (SM-G960F)
Android: 8.0.0 build: R16NW.G960FXXU1BRE5
2. Pixel2
Android: 9 build: PPP3.180510.008
3. Galaxy A3 (SM-A320FL)
Android: 7.0 build: NRD90M.A320FLXXS2BRAA
The three attachments included are: The built apk, the source code and a video displaying the issue.
The video showcases the app running on Galaxy S9 (Phone 1) with the following order:
1. Set "Don't keep activities" to enabled.
2. Happy case when everything is correct and onCleared() is called.
3. Fault case when the home button is pushed and onCleared() __is not called__.
I have this problem on all my devices. Here are some of them:
1. Samsung Galaxy S9 (SM-G960F)
Android: 8.0.0 build: R16NW.G960FXXU1BRE5
2. Pixel2
Android: 9 build: PPP3.180510.008
3. Galaxy A3 (SM-A320FL)
Android: 7.0 build: NRD90M.A320FLXXS2BRAA
The three attachments included are: The built apk, the source code and a video displaying the issue.
The video showcases the app running on Galaxy S9 (Phone 1) with the following order:
1. Set "Don't keep activities" to enabled.
2. Happy case when everything is correct and onCleared() is called.
3. Fault case when the home button is pushed and onCleared() __is not called__.
pa...@gmail.com <pa...@gmail.com> #6
I was able to reproduce this with "Don't keep activities" on.
Fragments currently use the fact that the system called onSaveInstanceState() as a marker on whether the Activity could be recreated. "Don't keep activities" specifically breaks that assumption by saving the instance state, then immediately throwing it away.
In a typical system, the only time that saved instance state would be thrown away would be if your process is being destroyed, of which there is no callback (either to your app or to ViewModels). Therefore this bug is limited to only devices using "Don't keep activities".
Saved state is an imperfect signal here, so we'll switch to the correct signal - Activity.isChangingConfigurations().
Fragments currently use the fact that the system called onSaveInstanceState() as a marker on whether the Activity could be recreated. "Don't keep activities" specifically breaks that assumption by saving the instance state, then immediately throwing it away.
In a typical system, the only time that saved instance state would be thrown away would be if your process is being destroyed, of which there is no callback (either to your app or to ViewModels). Therefore this bug is limited to only devices using "Don't keep activities".
Saved state is an imperfect signal here, so we'll switch to the correct signal - Activity.isChangingConfigurations().
su...@gmail.com <su...@gmail.com> #7
@6 Please also try my sample. on my sample I didn't enable "don't keep activities".
ma...@gmail.com <ma...@gmail.com> #8
The issue with onCleared not being called on Fragment hosted ViewModels is fixed internally and will be available in future releases of fragments.
[Deleted User] <[Deleted User]> #9
@8 What release will that be? Will it be part of the support library?
dr...@gmail.com <dr...@gmail.com> #10
Every release of the 28.0.0 Fragments and 1.0.0 AndroidX Fragments released after June 29th contains this fix, including beta01 and rc01. If you're still having issues, please file a new bug with reproduction steps and a sample project.
dr...@gmail.com <dr...@gmail.com> #11
@10 Have you tested it on the issue I've presented too:
https://issuetracker.google.com/issues/76404690
?
Can you reproduce it there? If you can, it shouldn't be closed. If you can't maybe it should be closed too.
?
Can you reproduce it there? If you can, it shouldn't be closed. If you can't maybe it should be closed too.
mi...@gmail.com <mi...@gmail.com> #12
@10 OK seems it's also fixed. You should close it too.
ne...@gmail.com <ne...@gmail.com> #13
I would close it as "Working as Designed"😕
il...@google.com <il...@google.com> #14
Filing a new bug with a sample project that reproduces the issue you're still seeing is indeed the correct behavior. We don't support bug necromancy, particularly 30 releases after the original fix was shipped.
Description
Version used: 1.0.0-alpha09
Devices/Android versions reproduced on: Android 9 emulator
In our app, we use multiple NavHostFragment in one Activity, few of them have their own navGraph set in xml, say nav_subgraph_1, nav_subgraph_2.
In code, we use NavDeepLinkBuilder to navigate to a specified page.
NavDeepLinkBuilder(it)
.setGraph(R.navigation.nav_subgraph_1)
.setDestination(R.id.dest_in_subgraph1)
.createTaskStackBuilder()
.startActivities()
It leads a crash in setContentView since the dest_in_subgraph1 couldn't be found in nav_subgraph_2 (while parsing the second NavHostFragment in the same Activity)
Crash log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.testapp.mobile.android.staging.debug, PID: 12615
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testapp.mobile.android.staging.debug/com.testapp.mobile.android.ui.HomeActivity}: android.view.InflateException: Binary XML file line #85: Binary XML file line #85: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #85: Binary XML file line #85: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #85: Error inflating class fragment
Caused by: java.lang.IllegalStateException: unknown destination during deep link: com.testapp.mobile.android.staging.debug:id/an_id_set_in_graph
at androidx.navigation.NavController.onHandleDeepLink(NavController.java:546)
at androidx.navigation.NavController.onGraphCreated(NavController.java:466)
at androidx.navigation.NavController.setGraph(NavController.java:421)
at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:221)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2414)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1418)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1684)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1930)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3745)
at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:405)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:387)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.testapp.mobile.android.ui.HomeActivity.onCreate
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
E/AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)