pedrovgs / Lynx

Lynx is an Android library created to show a custom view with all the information Android logcat is printing, different traces of different levels will be rendererd to show from log messages to your application exceptions. You can filter this traces, share your logcat to other apps, configure the max number of traces to show or the sampling rate used by the library.
Apache License 2.0
780 stars 94 forks source link

Crash #18

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello I recently experienced a crash with the app:

Fatal Exception: java.lang.NullPointerException
       at com.github.pedrovgs.lynx.renderer.TraceRendererBuilder.getPrototypeClass(TraceRendererBuilder.java:53)
       at com.github.pedrovgs.lynx.renderer.TraceRendererBuilder.getPrototypeClass(TraceRendererBuilder.java:37)
       at com.pedrogomez.renderers.RendererBuilder.getItemViewType(RendererBuilder.java:88)
       at com.pedrogomez.renderers.RendererAdapter.getItemViewType(RendererAdapter.java:100)
       at android.widget.AbsListView$RecycleBin.getScrapView(AbsListView.java:8194)
       at android.widget.AbsListView.obtainView(AbsListView.java:2702)
       at android.widget.ListView.makeAndAddView(ListView.java:1811)
       at android.widget.ListView.fillUp(ListView.java:733)
       at android.widget.ListView.layoutChildren(ListView.java:1622)
       at android.widget.AbsListView.onLayout(AbsListView.java:2546)
       at android.view.View.layout(View.java:15664)
       at android.view.ViewGroup.layout(ViewGroup.java:4869)
       at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
       at android.view.View.layout(View.java:15664)
       at android.view.ViewGroup.layout(ViewGroup.java:4869)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
       at android.view.View.layout(View.java:15664)
       at android.view.ViewGroup.layout(ViewGroup.java:4869)
       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
       at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
       at android.view.View.layout(View.java:15664)
       at android.view.ViewGroup.layout(ViewGroup.java:4869)
       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
       at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
       at android.view.View.layout(View.java:15664)
       at android.view.ViewGroup.layout(ViewGroup.java:4869)
       at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2246)
       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1968)
       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1200)
       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
       at android.view.Choreographer.doCallbacks(Choreographer.java:603)
       at android.view.Choreographer.doFrame(Choreographer.java:573)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
       at android.os.Handler.handleCallback(Handler.java:733)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:157)
       at android.app.ActivityThread.main(ActivityThread.java:5335)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
       at dalvik.system.NativeStart.main(NativeStart.java)
pedrovgs commented 8 years ago

Hi @ghost thanks for reporting the bug. I think this bug could be an easy to fix issue :) Maybe a project collaborator could help :) cc/ @Aracem @JcMinarro

JcMinarro commented 8 years ago

Hi @ghost which version are you using? Could you tell us how to reproduce this bug?

vic-gonzi commented 8 years ago

Hi all. I've investigated this issue, it's quite strange.

According to the trace, the problem starts in RendererAdapter.java:100 . One line before, getItem(position) seems to get a null reference, which is never checked and it crashes with NPE later on.

So, a null trace value is pushed somewhere. But the only point where new entries are added, is in Logcat::readLogcat() method, which has a null check before pushing new traces. Also, Trace::fromString(String) utility method rejects null values.

So apparently the architecture already rejects null values, but @ghost found a corner case where at least one is pushed.

@pedrovgs Maybe it's better to modify renderers library itself, and ensure no null values are pushed into RendererAdapter instances.

pedrovgs commented 8 years ago

@vic-gonzi with the last renderers version I've published this bug should be fixed. Could you get some time to send a PR with the update? Once the renderers library be updated we can close this bug.

vic-gonzi commented 8 years ago

@pedrovgs Let´s kill it. https://github.com/pedrovgs/Lynx/pull/21