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

SvgSupport (and possibly others) print stacktraces to consoles when class lookup fails #160

Closed
ZacSweers opened this issue Aug 24, 2019 · 2 comments
Milestone

Comments

@ZacSweers
Copy link

Markwon 4.1.0

SvgSupport tries to reflectively look up a supported class, and when it fails (which is a common case), it prints the entire stacktrace to console. This makes things noisy considering it's a common case.

2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/caverock/androidsvg/SVG;
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.svg.SvgSupport.<clinit>(SvgSupport.java:13)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.svg.SvgSupport.hasSvgSupport(SvgSupport.java:23)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.AsyncDrawableLoaderBuilder.<init>(AsyncDrawableLoaderBuilder.java:38)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.ImagesPlugin.<init>(ImagesPlugin.java:79)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.ImagesPlugin.create(ImagesPlugin.java:65)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule$Companion.markwon$catchup_debug(ApplicationModule.kt:109)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule.markwon$catchup_debug(Unknown Source:2)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule_Markwon$catchup_debugFactory.markwon$catchup_debug(ApplicationModule_Markwon$catchup_debugFactory.java:36)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule_Markwon$catchup_debugFactory.get(ApplicationModule_Markwon$catchup_debugFactory.java:27)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule_Markwon$catchup_debugFactory.get(ApplicationModule_Markwon$catchup_debugFactory.java:10)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.DaggerApplicationComponent$AboutActivitySubcomponentImpl$AboutFragmentSubcomponentImpl.injectAboutFragment(DaggerApplicationComponent.java:1244)
2019-08-24 19:00:10.304 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.DaggerApplicationComponent$AboutActivitySubcomponentImpl$AboutFragmentSubcomponentImpl.inject(DaggerApplicationComponent.java:1238)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.DaggerApplicationComponent$AboutActivitySubcomponentImpl$AboutFragmentSubcomponentImpl.inject(DaggerApplicationComponent.java:1231)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.DispatchingAndroidInjector.maybeInject(DispatchingAndroidInjector.java:113)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.DispatchingAndroidInjector.inject(DispatchingAndroidInjector.java:134)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.support.AndroidSupportInjection.inject(AndroidSupportInjection.java:93)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.support.AndroidSupportInjection.inject(AndroidSupportInjection.java:67)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.base.ui.InjectableBaseFragment.onAttach(InjectableBaseFragment.kt:24)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.Fragment.performAttach(Fragment.java:2643)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1268)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1199)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1082)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:119)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2282)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2240)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:2112)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:297)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.ui.about.AboutActivity.onCreate(AboutActivity.kt:432)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.Activity.performCreate(Activity.java:7802)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.Activity.performCreate(Activity.java:7791)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:107)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.os.Looper.loop(Looper.java:214)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7356)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.caverock.androidsvg.SVG" on path: DexPathList[[zip file "/data/app/io.sweers.catchup.debug-dRQyoBXHs22o_vSvq4mtzg==/base.apk"],nativeLibraryDirectories=[/data/app/io.sweers.catchup.debug-dRQyoBXHs22o_vSvq4mtzg==/lib/arm64, /data/app/io.sweers.catchup.debug-dRQyoBXHs22o_vSvq4mtzg==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2019-08-24 19:00:10.305 31864-31864/io.sweers.catchup.debug W/System.err: 	... 44 more
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err: java.lang.NoClassDefFoundError: Failed resolution of: Lpl/droidsonroids/gif/GifDrawable;
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.gif.GifSupport.<clinit>(GifSupport.java:13)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.gif.GifSupport.hasGifSupport(GifSupport.java:23)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.AsyncDrawableLoaderBuilder.<init>(AsyncDrawableLoaderBuilder.java:42)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.ImagesPlugin.<init>(ImagesPlugin.java:79)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.noties.markwon.image.ImagesPlugin.create(ImagesPlugin.java:65)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule$Companion.markwon$catchup_debug(ApplicationModule.kt:109)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule.markwon$catchup_debug(Unknown Source:2)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule_Markwon$catchup_debugFactory.markwon$catchup_debug(ApplicationModule_Markwon$catchup_debugFactory.java:36)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule_Markwon$catchup_debugFactory.get(ApplicationModule_Markwon$catchup_debugFactory.java:27)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.ApplicationModule_Markwon$catchup_debugFactory.get(ApplicationModule_Markwon$catchup_debugFactory.java:10)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
2019-08-24 19:00:10.306 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.DaggerApplicationComponent$AboutActivitySubcomponentImpl$AboutFragmentSubcomponentImpl.injectAboutFragment(DaggerApplicationComponent.java:1244)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.DaggerApplicationComponent$AboutActivitySubcomponentImpl$AboutFragmentSubcomponentImpl.inject(DaggerApplicationComponent.java:1238)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.app.DaggerApplicationComponent$AboutActivitySubcomponentImpl$AboutFragmentSubcomponentImpl.inject(DaggerApplicationComponent.java:1231)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.DispatchingAndroidInjector.maybeInject(DispatchingAndroidInjector.java:113)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.DispatchingAndroidInjector.inject(DispatchingAndroidInjector.java:134)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.support.AndroidSupportInjection.inject(AndroidSupportInjection.java:93)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at dagger.android.support.AndroidSupportInjection.inject(AndroidSupportInjection.java:67)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.base.ui.InjectableBaseFragment.onAttach(InjectableBaseFragment.kt:24)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.Fragment.performAttach(Fragment.java:2643)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1268)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1199)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1082)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:119)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2282)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2240)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:2112)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:297)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at io.sweers.catchup.ui.about.AboutActivity.onCreate(AboutActivity.kt:432)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.Activity.performCreate(Activity.java:7802)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.Activity.performCreate(Activity.java:7791)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:107)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.os.Looper.loop(Looper.java:214)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7356)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "pl.droidsonroids.gif.GifDrawable" on path: DexPathList[[zip file "/data/app/io.sweers.catchup.debug-dRQyoBXHs22o_vSvq4mtzg==/base.apk"],nativeLibraryDirectories=[/data/app/io.sweers.catchup.debug-dRQyoBXHs22o_vSvq4mtzg==/lib/arm64, /data/app/io.sweers.catchup.debug-dRQyoBXHs22o_vSvq4mtzg==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
2019-08-24 19:00:10.307 31864-31864/io.sweers.catchup.debug W/System.err: 	... 44 more

@noties
Copy link
Owner

noties commented Aug 26, 2019

Hello @ZacSweers !

I agree that printing stacktrace in case of missing classes can be noisy. I wanted to make it obvious and developer be aware of the issue (if it's present) because right now ImagesPlugin registers some media decoders implicitly. Let me remove this logging. Of cause an exception is still thrown when media decoder (SVG or GIF) is added explicitly without dependencies satisfied.

P.S. do you want me to add your app to the awesome section of documentation? 😄

@noties noties added this to the 4.1.1 milestone Aug 26, 2019
@noties
Copy link
Owner

noties commented Aug 26, 2019

Pushing new 4.1.1-SNAPSHOT version right now. I removed printing of stacktrace, instead a single warning statement is logged.

@noties noties mentioned this issue Aug 29, 2019
noties added a commit that referenced this issue Aug 29, 2019
* `markwon-ext-tables`: fix padding between subsequent table blocks ([#159])
* `markwon-images`: print a single warning instead full stacktrace in case when SVG or GIF 
are not present in the classpath ([#160])
* Make `Markwon` instance thread-safe by using a single `MarkwonVisitor` for each `render` call ([#157])
* Add `CoreProps.CODE_BLOCK_INFO` with code-block info (language)

[#159]: #159
[#160]: #160
[#157]: #157
@noties noties closed this as completed Aug 29, 2019
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

2 participants