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

[Bug]: Memory Leak PermissionsActivity #1790

Closed
1 task done
ngoni opened this issue Jul 30, 2023 · 3 comments
Closed
1 task done

[Bug]: Memory Leak PermissionsActivity #1790

ngoni opened this issue Jul 30, 2023 · 3 comments

Comments

@ngoni
Copy link

ngoni commented Jul 30, 2023

What happened?

When testing the In-App Push Permission Prompt on a new installation, I'm getting a memory leak error from LeakCanary.
To get the Permission Prompt to display in my app, I use a manual app trigger

OneSignal.InAppMessages.addTrigger("showPrompt", "true")

Steps to reproduce?

1. Install v5.0.0-beta4 library of the SDK
2. Install LeakCanary library in your sample app
3. On your OneSignal dashboard account, enable the `In-App Push Permission Prompt`. In my case, the Permission Prompt is displayed when I send a trigger condition. e.g. `OneSignal.InAppMessages.addTrigger("showPrompt", "true")`
4. Click `Allow` when the Push Permission Prompt displays, so this shows the native Android Permissions dialog. (Assuming you're using the template Push Permission Prompt example provided on the dashboard)
5. On the native Android Permissions dialog, click `Allow`
6. When the native Android Permissions dialog is dismissed, you'll notice the memory leak shown in LeakCanary

What did you expect to happen?

No memory leaks when displaying an In-App Push Permission Prompt

OneSignal Android SDK version

Release 5.0.0-beta4

Android version

13

Specific Android models

Android Studio Emulator on Android 13

Relevant log output

┬───
│ GC Root: Thread object
│
├─ android.net.ConnectivityThread instance
│ Leaking: NO (PathClassLoader↓ is not leaking)
│ Thread name: 'ConnectivityThread'
│ ↓ Thread.contextClassLoader
├─ dalvik.system.PathClassLoader instance
│ Leaking: NO (OneSignal↓ is not leaking and A ClassLoader is never leaking)
│ ↓ ClassLoader.runtimeInternalObjects
├─ java.lang.Object[] array
│ Leaking: NO (OneSignal↓ is not leaking)
│ ↓ Object[1245]
├─ com.onesignal.OneSignal class
│ Leaking: NO (a class is never leaking)
│ ↓ static OneSignal.oneSignal$delegate~~~~~~~~~~~~~~~~~~
├─ kotlin.SynchronizedLazyImpl instance
│ Leaking: UNKNOWN
│ Retaining 24.5 kB in 863 objects
│ ↓ SynchronizedLazyImpl._value
│ ~~~~~~
├─ com.onesignal.internal.OneSignalImp instance
│ Leaking: UNKNOWN
│ Retaining 24.5 kB in 862 objects
│ ↓ OneSignalImp._iam
│ ~~~~
├─ com.onesignal.inAppMessages.internal.InAppMessagesManager instance
│ Leaking: UNKNOWN
│ Retaining 1.7 kB in 54 objects
│ ↓ InAppMessagesManager._displayer
│ ~~~~~~~~~~
├─ com.onesignal.inAppMessages.internal.display.impl.InAppDisplayer instance
│ Leaking: UNKNOWN
│ Retaining 174.4 kB in 2874 objects
│ ↓ InAppDisplayer.lastInstance
│ ~~~~~~~~~~~~
├─ com.onesignal.inAppMessages.internal.display.impl.WebViewManager instance
│ Leaking: UNKNOWN
│ Retaining 174.4 kB in 2873 objects
│ activity instance of com.onesignal.core.activities.PermissionsActivity
│ with mDestroyed = true
│ ↓ WebViewManager.activity
│ ~~~~~~~~
╰→ com.onesignal.core.activities.PermissionsActivity instance
     Leaking: YES (ObjectWatcher was watching this because com.onesignal.core.
     activities.PermissionsActivity received Activity#onDestroy() callback and
     Activity#mDestroyed is true)
     Retaining 36.1 kB in 479 objects
     key = b3bfcfba-b2ca-4000-a636-150c67fc8290
     watchDurationMillis = 9880
     retainedDurationMillis = 4877
     _requestPermissionService instance of com.onesignal.core.internal.
     permissions.impl.RequestPermissionService with mDestroyed = false
     mApplication instance of com.example.App
     mBase instance of android.app.ContextImpl

METADATA

Build.VERSION.SDK_INT: 33
Build.MANUFACTURER: Google
LeakCanary version: 2.9.1
App process name: com.example.App.debug
Class count: 35722
Instance count: 266771
Primitive array count: 165708
Object array count: 42726
Thread count: 88
Heap total bytes: 39292859
Bitmap count: 12
Bitmap total bytes: 36444
Large bitmap count: 0
Large bitmap total bytes: 0
Db 1: open /data/user/0/com.example.App.debug/databases/com.google.
android.datatransport.events
Db 2: closed /data/user/0/com.example.App.
debug/databases/google_app_measurement_local.db
Db 3: open /data/user/0/com.example.App.debug/databases/OneSignal.db
Db 4: open /data/user/0/com.example.App.debug/databases/userEvent.db
Db 5: open /data/user/0/com.example.App.debug/no_backup/androidx.work.
workdb
Stats: LruCache[maxSize=3000,hits=127958,misses=268892,hitRate=32%]
RandomAccess[bytes=13774209,reads=268892,travel=122701904683,range=45001585,size
=55975557]
Analysis duration: 8093 ms

Code of Conduct

  • I agree to follow this project's Code of Conduct
@nan-li nan-li added the Beta label Jul 31, 2023
@emawby emawby added the Bug label Jul 31, 2023
@jennantilla
Copy link
Contributor

Hello @ngoni apologies that this issue was missed.

Is this still a concern for you? Since your report we have a major release out; can you please update to our latest SDK version and let us know if you are still seeing this?

Thank you!

@ngoni
Copy link
Author

ngoni commented Jul 2, 2024

@jennantilla Sorry only seeing this now. I will test and let you know

@jennantilla
Copy link
Contributor

Hello there! We're going to close this issue as it has gone stale. If you are still having any trouble after updating to our latest SDK version, please open a new issue and we'll be happy to assist. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants