Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

destroy views on unmount #45

Merged
merged 3 commits into from
Jul 6, 2020

Conversation

aminghorbankhani
Copy link
Contributor

Thanks for your package. It really helps us in our project.

This PR fixes memory leak we are seeing in our stress test, which is an auto navigation between different pages of our app, some of which have 1 or few native ads in flat lists, section lists, and scroll views.

Here is also a possibly related error captured by human testers:

java.lang.IllegalStateException Too many receivers, total of 1000, registered for pid: 1458, callerPackage: ...
    Parcel.java:2096 android.os.Parcel.createException
    Parcel.java:2056 android.os.Parcel.readException
    Parcel.java:2004 android.os.Parcel.readException
    IActivityManager.java:5595 android.app.IActivityManager$Stub$Proxy.registerReceiver
    ContextImpl.java:1589 android.app.ContextImpl.registerReceiverInternal
    ContextImpl.java:1550 android.app.ContextImpl.registerReceiver
    ContextImpl.java:1538 android.app.ContextImpl.registerReceiver
    ContextWrapper.java:641 android.content.ContextWrapper.registerReceiver
    :com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:7 com.google.android.gms.ads.internal.util.br.a
    :com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:6 com.google.android.gms.ads.internal.activeview.ac.a
    :com.google.android.gms.policy_ads_fdr_dynamite@[email protected] com.google.android.gms.ads.internal.activeview.ac.onViewAttachedToWindow
    View.java:21318 android.view.View.dispatchAttachedToWindow
    ViewGroup.java:4239 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:4246 android.view.ViewGroup.dispatchAttachedToWindow
    ViewGroup.java:6001 android.view.ViewGroup.addViewInner
    ViewGroup.java:5934 android.view.ViewGroup.addViewInLayout
    ReactViewGroup.java:380 com.facebook.react.views.view.ReactViewGroup.updateSubviewClipStatus
    ReactViewGroup.java:420 com.facebook.react.views.view.ReactViewGroup.updateSubviewClipStatus
    ReactViewGroup.java:53 com.facebook.react.views.view.ReactViewGroup.access$000
    ReactViewGroup.java:94 com.facebook.react.views.view.ReactViewGroup$ChildrenLayoutChangeListener.onLayoutChange
    View.java:23771 android.view.View.layout
    ViewGroup.java:7277 android.view.ViewGroup.layout
    NativeViewHierarchyManager.java:251 com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout
    NativeViewHierarchyManager.java:219 com.facebook.react.uimanager.NativeViewHierarchyManager.updateLayout
    UIViewOperationQueue.java:154 com.facebook.react.uimanager.UIViewOperationQueue$UpdateLayoutOperation.execute
    UIViewOperationQueue.java:779 com.facebook.react.uimanager.UIViewOperationQueue$1.run
    UIViewOperationQueue.java:888 com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches
    UIViewOperationQueue.java:42 com.facebook.react.uimanager.UIViewOperationQueue.access$2200
    UIViewOperationQueue.java:948 com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded
    GuardedFrameCallback.java:28 com.facebook.react.uimanager.GuardedFrameCallback.doFrame
    ReactChoreographer.java:174 com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame
    ChoreographerCompat.java:84 com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame
    Choreographer.java:997 android.view.Choreographer$CallbackRecord.run
    Choreographer.java:797 android.view.Choreographer.doCallbacks
    Choreographer.java:728 android.view.Choreographer.doFrame
    Choreographer.java:984 android.view.Choreographer$FrameDisplayEventReceiver.run
    Handler.java:883 android.os.Handler.handleCallback
    Handler.java:100 android.os.Handler.dispatchMessage
    Looper.java:237 android.os.Looper.loop
    ActivityThread.java:8016 android.app.ActivityThread.main
    Method.java:-2 java.lang.reflect.Method.invoke
    RuntimeInit.java:493 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run
    ZygoteInit.java:1076 com.android.internal.os.ZygoteInit.main

Caused by: android.os.RemoteException Remote stack trace:
	at com.android.server.am.ActivityManagerService.registerReceiver(ActivityManagerService.java:17136)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2269)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3359)
	at android.os.Binder.execTransactInternal(Binder.java:1021)
	at android.os.Binder.execTransact(Binder.java:994)
 
    unknown file unknown method

Also we are investigating another possible leak caused by low values of refresh interval, e.g. 1 minute.

@aminghorbankhani
Copy link
Contributor Author

aminghorbankhani commented Jul 1, 2020

@ammarahm-ed
Copy link
Owner

Thanks for the fixes above. I will merge these for the next release

@ammarahm-ed ammarahm-ed merged commit 7a0a37b into ammarahm-ed:master Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants