getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.16k stars 435 forks source link

Session Replay for Compose leak #3915

Open romtsn opened 5 days ago

romtsn commented 5 days ago

Integration

sentry-android

Build System

Gradle

AGP Version

...

Proguard

Disabled

Version

7.18.0

Steps to Reproduce

Caught by LeakCanary

                              ====================================
  HEAP ANALYSIS RESULT
  ====================================
  1 APPLICATION LEAKS

  References underlined with "~~~" are likely causes.
  Learn more at https://squ.re/leaks.

  76166 bytes retained by leaking objects
  Signature: b3a97afc793268893ebb51b45a46b38ebc0d3d09
  ┬───
  │ 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 (ComposeViewHierarchyNode↓ is not leaking and A ClassLoader is never leaking)
  │    ↓ ClassLoader.runtimeInternalObjects
  ├─ java.lang.Object[] array
  │    Leaking: NO (ComposeViewHierarchyNode↓ is not leaking)
  │    ↓ Object[1344]
  ├─ io.sentry.android.replay.viewhierarchy.ComposeViewHierarchyNode class
  │    Leaking: NO (a class is never leaking)
  │    ↓ static ComposeViewHierarchyNode._rootCoordinates
  │                                      ~~~~~~~~~~~~~~~~
  ├─ androidx.compose.ui.node.InnerNodeCoordinator instance
  │    Leaking: UNKNOWN
  │    Retaining 102.2 kB in 1973 objects
  │    ↓ NodeCoordinator.layoutNode
  │                      ~~~~~~~~~~
  ├─ androidx.compose.ui.node.LayoutNode instance
  │    Leaking: UNKNOWN
  │    Retaining 1.1 kB in 36 objects
  │    ↓ LayoutNode.owner
  │                 ~~~~~
  ├─ androidx.compose.ui.platform.AndroidComposeView instance
  │    Leaking: YES (View.mContext references a destroyed activity)
  │    Retaining 76.2 kB in 1303 objects
  │    View is part of a window view hierarchy
  │    View.mAttachInfo is null (view detached)
  │    View.mWindowAttachCount = 1
  │    mContext instance of io.sentry.samples.android.SplashActivity with mDestroyed = true
  │    ↓ View.mContext
  ╰→ io.sentry.samples.android.SplashActivity instance
  ​     Leaking: YES (ObjectWatcher was watching this because io.sentry.samples.android.SplashActivity received
  ​     Activity#onDestroy() callback and Activity#mDestroyed is true)
  ​     Retaining 15.2 kB in 324 objects
  ​     key = dbf099f6-d3e4-465c-b17f-7ba3dfa82311
  ​     watchDurationMillis = 16002
  ​     retainedDurationMillis = 11001
  ​     mApplication instance of io.sentry.samples.android.MyApplication
  ​     mBase instance of androidx.appcompat.view.ContextThemeWrapper
  ====================================

Expected Result

Don't leak

Actual Result

Leaks