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

Obfucation and 2.8.1 version cause an app launch crash #2286

Closed
martynamaron opened this issue Jan 12, 2022 · 6 comments · Fixed by #2359
Closed

Obfucation and 2.8.1 version cause an app launch crash #2286

martynamaron opened this issue Jan 12, 2022 · 6 comments · Fixed by #2359
Milestone

Comments

@martynamaron
Copy link

Description

When building the app with LeakCanary v2.8.1 and obfuscation enabled, the app launch crashes with the following:

Fatal Exception: java.lang.NullPointerException
curtains.internal.WindowCallbackWrapper$Companion.getJetpackWrapped (WindowCallbackWrapper.kt:112)
curtains.internal.WindowCallbackWrapper$Companion.unwrap (WindowCallbackWrapper.kt:154)
curtains.WindowsKt.getWrappedCallback (Windows.kt:233)
leakcanary.RootViewWatcher$listener$1.onRootViewAdded (RootViewWatcher.kt:46)
curtains.OnRootViewAddedListener$DefaultImpls.onRootViewsChanged (Listeners.kt:38)
leakcanary.RootViewWatcher$listener$1.onRootViewsChanged (RootViewWatcher.kt:43)
curtains.internal.RootViewsSpy$delegatingViewList$1.add (RootViewsSpy.kt:25)
curtains.internal.RootViewsSpy$delegatingViewList$1.add (RootViewsSpy.kt:23)
android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:454)
android.view.WindowManagerImpl.addView (WindowManagerImpl.java:121)
android.app.ActivityThread.handleResumeActivity (ActivityThread.java:5012)
android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:52)
android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:190)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:105)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:2462)
android.os.Handler.dispatchMessage (Handler.java:110)
android.os.Looper.loop (Looper.java:219)
android.app.ActivityThread.main (ActivityThread.java:8393)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:513)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1055)

Steps to Reproduce

When using LeakCanary dependency of 2.8.1 and minifyEnabled and shrinkResources both set to true, the app launch crashes.

Using this dependency might also contribute to the crash: androidx.window:window:1.0.0-rc01

Expected behavior:
The app shouldn't crash

Version Information

  • LeakCanary version: 2.8.1
  • Android OS version: API 31
  • Gradle version: 7.0.2

Additional Information

Using LeakCanary 2.8 does not produce the crash, even if the WindowManager dependency (androidx.window:window:1.0.0-rc01) is still in use then.

Any additional information, configuration or data that might be necessary to reproduce the issue.

@gediseer
Copy link

gediseer commented Jan 21, 2022

Facing the same crash, can you fix it, looks like it blocks most projects targeting 31 work.

01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: java.lang.NullPointerException
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at curtains.internal.WindowCallbackWrapper$Companion.getJetpackWrapped(WindowCallbackWrapper.kt:1)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at curtains.internal.WindowCallbackWrapper$Companion.unwrap(WindowCallbackWrapper.kt:2)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at curtains.WindowsKt.getWrappedCallback(Windows.kt:1)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at leakcanary.RootViewWatcher$listener$1.onRootViewAdded(RootViewWatcher.kt:3)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at curtains.OnRootViewAddedListener$DefaultImpls.onRootViewsChanged(Listeners.kt:1)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at leakcanary.RootViewWatcher$listener$1.onRootViewsChanged(RootViewWatcher.kt:1)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at curtains.internal.RootViewsSpy$delegatingViewList$1.add(RootViewsSpy.kt:4)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at curtains.internal.RootViewsSpy$delegatingViewList$1.add(RootViewsSpy.kt:1)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:454)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:114)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5014)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2336)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.os.Looper.loop(Looper.java:246)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8653)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
01-20 10:46:59.432 10665  4863  4863 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

@rvp-diconium
Copy link

+1 reproducible crash on 2.8 and 2.8.1

@andreya108
Copy link

andreya108 commented Feb 9, 2022

+1
Something goes wrong with minifyEnabled

@dEn13L
Copy link

dEn13L commented Feb 17, 2022

This crash happens because curtains library uses reflection to get WindowCallbackWrapper class

Just add keep rules in your debug progurd rules

-keep class androidx.appcompat.view.WindowCallbackWrapper { *; }
-keep class android.support.v7.view.WindowCallbackWrapper { *; }

see square/curtains#32

@square square deleted a comment from runmael Apr 3, 2022
@square square deleted a comment from tronku Apr 3, 2022
@square square deleted a comment from zsperske Apr 3, 2022
@square square deleted a comment from pstambrecht Apr 3, 2022
@pyricau
Copy link
Member

pyricau commented Apr 3, 2022

We'll eventually ship with those proguard rules, but in the meantime you can add them to your project directly.

I just removed a bunch of +1 comments. Please don't do that.

@pyricau
Copy link
Member

pyricau commented Apr 15, 2022

We need a new release of Curtains and then bump the dependency in LeakCanary.

@pyricau pyricau added this to the 2.9 milestone Apr 15, 2022
@pyricau pyricau mentioned this issue Apr 16, 2022
pyricau added a commit that referenced this issue Apr 16, 2022
New release includes Proguard rule to keep appcompat WindowCallbackWrapper class

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

Successfully merging a pull request may close this issue.

6 participants