Replies: 5 comments 2 replies
-
Why don't you just keep the same instance of ARFragment, remove the old object from the scene, then add the new object? You could use the Activity common to the fragments to communicate which objects to show in the ARFragment view, rather than using the navigation component. |
Beta Was this translation helpful? Give feedback.
-
@frederic-c-dcode is right First, it's true that we don't have the hand on the Anyway you might be facing a consuming issue that shouldn't happen and be sure we are hardly working on it. Could you then send some performance monitor screenshots to help going further on your memory issue? |
Beta Was this translation helpful? Give feedback.
-
@frederic-c-dcode @ThomasGorisse Thanks for the fast response. The application is quite complex with a lot of different screens(nav graphs and nested ones), so I need to remove ArFragment and add it back when it's necessary, otherwise, I'll have a laggy app. So for that matter, my users must scan for planes every time they select a model from a previous fragment. I had a FragmentContainerView in MainActivity and when I got to the desired fragment when I needed it, I would add ArFragment with fragment transactions to Activity's supportFragmentManager, initialize listeners in OnAttachFragmentListener, and on destroying current fragment, removing ArFragment from fragment transactions with Activity's supportFragmentManager. Results with memory are the same, and the app still crashes when it's got to the usage of around 2Gb without some log information. I'll provide Memory Profiler screenshots as soon as I can. Edit: So I was investigating a bit and there were 2 leaks, one connected with my fragment, that I fixed by setting TapListener and SessionConfigurationListener on null while destroying. But this one is left My CustomARFragment is just this:
|
Beta Was this translation helpful? Give feedback.
-
LeakCanary
|
Beta Was this translation helpful? Give feedback.
-
This lambda leaks a reference to your activity. https://github.com/ThomasGorisse/sceneform-android-sdk/blob/56cf752680206829296832719161c8e37453e9ca/ux/src/main/java/com/google/ar/sceneform/ux/BaseArFragment.java#L81-L82 |
Beta Was this translation helpful? Give feedback.
-
Hello,
So I'm having a hard time with implementing ARFragment in Fragment. The current flow of the application is that we have a fragment(A) with a list of models from which you can pick one and send it with the navigation component to another fragment(B). That fragment contains FragmentContainerView and several other Views.
In that Fragment(B) we are using fragment transaction with childFragmentManager to add fragment. Fragment is initialized successfully every time and childFragmentManager contains only that ARFragment.
The problem is, however, if I go back and pick another model or the same one and re-enter fragment(B), that fragment B is initialized successfully again, but it is laggier and the memory profiler shows more memory usage than the first time.
By repeating this process, the newly initialized ARFragment is always laggier until the app just stops working, with no explanation, probably big memory usage.
childFragmentManager contains no fragments on creating fragment B. I tried with ARFragment's onDestroy, onStop, onResume, but nothing helps. Also, I tried using supportFragmentManager with Activity that contains that fragment B, also unsuccessfully.
Is that fragment still somewhere in memory, I really need your help.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions