Android Shinobi Crashes


#1

Here are the 2 big Shinobi Crashes that our Android app is getting:

Crash 1: (We are using a ChartView not ChartFragment) Not sure where this one is coming from, we cannot reproduce it.

java.lang.NullPointerException: Attempt to invoke virtual method ‘void com.shinobicontrols.charts.SChartGLDrawer.setFrameBufferSize(int, int)’ on a null object reference

1

at com.shinobicontrols.charts.x.onSurfaceChanged (SourceFile:170)

 

2

at com.shinobicontrols.charts.GLTextureView$f.l (SourceFile:1598)

 

3

at com.shinobicontrols.charts.GLTextureView$f.run (SourceFile:1310)

Crash 2: This one is reproducable when we animate the charts from visible to gone while they are still drawing. But it happens in several other scenarios too.

java.lang.NullPointerException: Attempt to invoke virtual method ‘double java.lang.Double.doubleValue()’ on a null object reference

1

at com.shinobicontrols.charts.NumberAxis.a (SourceFile:326)

 

2

at com.shinobicontrols.charts.dg.e (SourceFile:224)

 

3

at com.shinobicontrols.charts.dg.d (SourceFile:161)

 

4

at com.shinobicontrols.charts.dg.a (SourceFile:58)

 

5

at com.shinobicontrols.charts.Axis.a (SourceFile:2453)

 

6

at com.shinobicontrols.charts.w.a (SourceFile:315)

 

7

at com.shinobicontrols.charts.s.onDraw (SourceFile:54)

 

1 non-project frame

 

 

9

at com.shinobicontrols.charts.s.draw (SourceFile:64)

 

5 non-project frames

 

 

15

at com.shinobicontrols.charts.w.dispatchDraw (SourceFile:192)

 

83 non-project frames

 

 

Please help us resolve these. Thanks


#2

Hi bwhite,

I’m also using ChartView within a Fragment to support Nested Fragments as described here and I can confirm your crash 1. Even tough I’m forwarding the lifecycle calls from the Fragment as recommended.

For me it’s the only noteworthy crash I get with around 1-2% of my users affected.

The crash seems to be randomly distributed over my users devices: https://dl.dropboxusercontent.com/u/52434/Shinobi%20Crash.png

I would be happy if someone might have a fix for this.


#3

Hi bwhite and sdeff,

Thanks for bringing these crashes to our attention.

Crash 1
This certainly does look like the lifecycle calls are not being forwarded on to the ChartView, but obviously this isn’t the case for sdeff. bwhite, have you also ensured you are forwarding on the lifecycle calls from the Fragment to the ChartView? The onPause and onResume calls are the critical ones.

Could you both expand a little more on how the ChartView is being used? For example, sdeff you mention Nested Fragments - is this to put the Fragments in a ViewPager? The more detail the better. I know bwhite said it can’t be reproduced, am I right in thinking this is the same for you, sdeff? If you’d rather not talk about specifics of your app on a public forum you can email info@shinobicontrols.com - if it’s at all possible to send a cut-down sample app that just gives an idea of the basic structure of your app (at least the bit with the charts in) that would be a great starting point even if it doesn’t reproduce the error.

Crash 2
We have recently found a bug in the library where you will receive a similar crash when you add a series to the chart as hidden. Upon making it visible the exception is thrown. Essentially the problem is that in the measure cycle the axis not considering the range of data for that series (leaving it with an undefined range and no major tick frequency). Making the series visible only kicks off a draw, not a measure/layout meaning a NullPointerException is received due to an important variable not being initialised properly.

I appreciate you mention this can be reproduced by animating the chart from visible to gone while it is still drawing. Do you mean you are changing the visibility of the ChartView itself or are you using the series hiding and animation feature within the ChartView (i.e. you’re hiding a Series on the ChartView, not the ChartView as a whole)? Again, a cut-down sample app that reliably reproduces this problem would be very helpful in investigating this issue further. Also, what is the exact version of  shinobicharts that you are using? This information will help us to retrace the obfuscated stack trace in your post allowing me to confirm whether your crash is in the same area as the crashes resulting from the bug I described above.

Kind regards,

Pat


#4

Hi Patrick,

Thanks for your prompt response. The fragment is not within a ViewPager and I can’t reproduce the error. It seems to happen randomly to 1-2% of my users on various devices .

I do have a regular Fragment (WeightFragment) within an Activity. It contains it’s own content and another Fragment (WeightChartFragment) which inflates a single ChartView as it’s root view.

| > public class WeightFragment extends Fragment {

|   |
|   | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
|   | Bundle savedInstanceState) { |
|   | rootView = inflater.inflate(R.layout.fragment_weight, container, false); |
|   |   |
|   | … |

|   |   |
|   | if (weightChartFragment == null) { |
|   | weightChartFragment = new WeightChartFragment(); |
|   | weightChartFragment.setRetainInstance(true); |
|   | } |
|   | FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); |
|   | transaction.replace(R.id.fraghost, weightChartFragment, “WeightChartFragment”).commit(); |
|   |   |
|   | // Inflate the layout for this fragment |
|   | return rootView; |
|   | } |

|
|   |

publicclassWeightChartFragmentextendsFragment {

 

|   | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
|   | Bundle savedInstanceState) { |
|   |   |
|   | View rootView = inflater.inflate(R.layout.chart_view, container, false); |
|   |   |
|   | … |
|   | // ShinobiChart |
|   | chartView = (ChartView) rootView.findViewById(R.id.chart); |
|   | shinobiChart = chartView.getShinobiChart(); |
|   | setChart(); |
|   |   |
|   | // Inflate the layout for this fragment |
|   | return rootView; |
|   | } |
|   |   |
|   | @Override |
|   | public void onResume() { |
|   | super.onResume(); |
|   |   |
|   | if (chartView != null) { |
|   | // Ensure the GL views get to hear about the pause/resume events |
|   | chartView.onResume(); |
|   | } |
|   | } |
|   |   |
|   | @Override |
|   | public void onPause() { |
|   | super.onPause(); |
|   | if (chartView != null) { |
|   | // Ensure the GL views get to hear about the pause/resume events |
|   | chartView.onPause(); |
|   | } |
|   | } |

As you can see I do forward the lifecycle changes to the ChartView. (The setChart() method just adds the basic styling, series listeners to the chart.)

 

Maybe this already helps to find the problem but I will additionally send you a link to the full source code of those fragments via email.

 

Thanks for helping us.


#5

java.lang.NullPointerException: Attempt to invoke virtual method ‘void com.shinobicontrols.charts.SChartGLDrawer.setFrameBufferSize(int, int)’ on a null object reference

I can confirmed that this crash only happens on Android 5.x and above. Below are a list of devices I’ve tested on.

Samsung S3 4.1.2 - OK

LG something 4.1.2 - OK

Sony Z3 5.0.2 - Crash

Nexus 2012 5.1.0 - Crash

Nexus 2013 6.0.0 - Crash

Fyi, I’m using shinobicharts-android-premium-1.7.2-0


#6

Hi torinnguyen 

Sorry to hear you are experiencing crashes when using shinobicharts. Can you please advise what actions are being performed within the application to trigger the crash? Could you please give us an idea how your application is laid out? For example are you using nested fragments?

In the past we have experienced users seeing similar crashes when the chart has been asked to perform a draw cycle as it is placed into the background (for example if a dialog is brought into the foreground). We are not currently aware of any issues affecting only Android versions 5x. Are you able to reproduce the issue? If so could you please contact us at info@shinobicontrols.com and provide a small sample app which demonstrates the crash?

We look forward to hearing from you.

Thanks,

Kai.


#7

Ok. The problem was I wasn’t forwarding onResume & onPause call to ChartView. After adding those calls, everything is fine.

Btw, I’m not using nested Fragment, just a regular Activity with a Fragment.

The crash happens everytime the app is put to background and resume.


#8

Glad to hear you got it sorted torinnguyen! Yeah, if you don’t forward on the lifecycle calls when you try to resume the app, from it being in the background, you will encounter this error because the OpenGL context won’t have been properly set up.

Kind regards,

Patrick