Upgraded to version 2.9.8-3 now getting crashes



we updated our app from using version 2.6.1 to version 2.9.8-3 and the only changes we made were for changes to the api. Now however we are getting a lot of crashes of the app in the background.

The crashes are all as follows:

Application Specific Information:
*** Terminating app due to uncaught exception 'std::runtime_error', reason: 'Couldn't initialise glObject. This is likely a problem with the GL context.'

Last Exception Backtrace:
0   <App Name>                       0x00000001014e42e8 SChartGL::GLResources::glGen(unsigned int*, void (*)(int, unsigned int*)) + 144
1   <App Name>                       0x00000001015a4b60 SChartGL::VertexBuffer::VertexBuffer(std::__1::shared_ptr<SChartGL::ErrorHandlerHandle const>, SChartGL::VertexTraits const&) + 184
2   <App Name>                        0x00000001015a4bd8 SChartGL::VertexBuffer::VertexBuffer(std::__1::shared_ptr<SChartGL::ErrorHandlerHandle const>, SChartGL::VertexTraits const&) + 32
3   <App Name>                        0x0000000101549f68 SChartGL::BufferManager::setupBufferAndVBOs(SChartGL::GLResources&) + 360
4  <App Name>                        0x0000000101549dac SChartGL::BufferManager::BufferManager(SChartGL::GLResources&) + 200
5   <App Name>                        0x000000010154a1d8 SChartGL::BufferManager::BufferManager(SChartGL::GLResources&) + 32
6   <App Name>                        0x0000000101593f60 SChartGL::GLResources::GLResources(std::__1::shared_ptr<SChartGL::ErrorHandlerHandle const>) + 132
7  <App Name>                        0x0000000101594afc SChartGL::GLResources::GLResources(std::__1::shared_ptr<SChartGL::ErrorHandlerHandle const>) + 24
8  <App Name>                        0x0000000101561994 SChartGL::Drawer::Drawer(bool, SChartGL::ErrorHandlerHandle const*) + 284
9  <App Name>                        0x0000000101561c70 SChartGL::Drawer::Drawer(bool, SChartGL::ErrorHandlerHandle const*) + 44
10  <App Name>                        0x00000001014e573c -[SChartGLView drawer] + 188
11  <App Name>                        0x00000001014e5888 -[SChartGLView reset] + 100
12  <App Name>                        0x00000001014e5950 -[SChartGLView beginRenderWithReloadedData:] + 72
13  <App Name>                        0x00000001014ec558 -[SChartCanvas drawChart:] + 1228
14  <App Name>                        0x00000001014e8738 -[SChartCanvasRenderView drawRect:] + 76
15  UIKit                                0x000000018b097f60 -[UIView(CALayerDelegate) drawLayer:inContext:] + 532
16  QuartzCore                           0x00000001855bdba8 -[CALayer drawInContext:] + 292
17  QuartzCore                           0x00000001855bd2e8 -[CALayer _display] + 932
18  QuartzCore                           0x000000018552e8f4 CA::Context::commit_transaction(CA::Transaction*) + 512
19  QuartzCore                           0x0000000185556364 CA::Transaction::commit() + 576
20  QuartzCore                           0x00000001855571e4 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 88
21  CoreFoundation                       0x00000001813de910 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
22  CoreFoundation                       0x00000001813dc238 __CFRunLoopDoObservers + 408
23  CoreFoundation                       0x00000001813dc884 __CFRunLoopRun + 1432
24  CoreFoundation                       0x00000001812fcda8 CFRunLoopRunSpecific + 548
25  GraphicsServices                     0x00000001832e1020 GSEventRunModal + 96
26  UIKit                                0x000000018b319758 UIApplicationMain + 232
27  <App Name>                        0x0000000100d3b1f4 main (main.m:15)
28  libdyld.dylib                        0x0000000180d8dfc0 start + 0

Has a newer version of the charts resolved this? In another app I have gone down the path of adding code to call setIsEnteringBackground:YES and call flushPendingGLOperations but this never appears to solve the crashes. I think this is because the are some observer call backs happening before we can call above methods.

Can you please help!

Also what is Shinobiscontrols position on OpenGL now that Apple has deprecated it? Are you planning to migrate to Metal or something else?

Thanks Ants.


Hello Ants,
We’ve encountered issues like this before; in each case it was caused by the chart being asked to redraw in the background. Of course when you create a ShinobiChart on the background thread it does not have access to the OpenGL resources it needs.
I appreciate you mention that in another app you’ve used code to call setIsEnteringBackground:YES and call flushPendingGLOperations, without success. I do think however the issue here lies with the chart attempting to draw whilst in the background.
There is a newer version of shinobicharts available, but this does not address any bugs that cause crashes.
Can you please provide more detail about your app’s lifecycle in terms of foreground/background processes and how the charts fit into that? Are you able to reliably reproduce this crash?
For brevity, I’d like to mention that in the past, the following tips have helped developers overcome these crashes:

  1. In your app delegate’s applicationWillResignActive method, your app should call the chart’s flushPendingGLOperations method and call setisEnteringBackground(true) on the chart.
  2. If there is any code running on a background thread which updates the chart data, your app should avoid attempting to redraw the chart.
  3. In your app delegate’s applicationWillEnterForeground: method, your app should call setIsEnteringBackground(false) on the chart.
    In addition to this, one of our clients found that setting the chart to nil in -willResignActive and then reload the charts on activate completely resolved all crashes.
    I look forward to hearing from you soon.


Hi Kai,

thanks for your response.

In the app that has now started to present this issue after upgrading, it is using the charts in cells on a tableview. the charts are being populated from a -viewDidAppear: call which calls a method that loads the data in the background then dispatches back to foreground to load into the charts. There is no code to handle any backgrounding of the app.

I have tried repeatedly to reproduce this crash but have been unsuccessful. In my attempts I try to load the table view and exit immediately etc. Some have been able to reproduce this but only from time to time.

In the other app we implemented a class that monitors for applicationWillResignActive & applicationWillEnterForeground events and registered all view controllers that uses the charts with it. There it calls all the registered view controllers for those events and they call e.g.

[self.chartView flushPendingGLOperations];
[self.chartView setIsEnteringBackground:YES];


[self.chartView setIsEnteringBackground:NO];


Here is a screen grab from Hockey showing the app that now has the issue after upgrading:

We have a log that we upload to hockey when certain things happen (app events, view controllers being shown etc), it’s fairly brief (because only uploads on crashes) but for this app it does not even appear that we are using a chart and the crash still happens. e.g.

****** STARTING NEW LOG 2018-07-11 11:10:04 +0000 *******
2018-07-11 11:10:04 +0000: application:willFinishLaunchingWithOptions:
2018-07-11 11:10:04 +0000: application:didFinishLaunchingWithOptions:
2018-07-11 11:10:05 +0000: applicationDidBecomeActive:
2018-07-11 11:27:12 +0000: applicationWillResignActive:
2018-07-11 11:27:13 +0000: applicationDidEnterBackground:
2018-07-11 11:28:21 +0000: applicationWillEnterForeground: state = 2
2018-07-11 11:28:21 +0000: applicationDidBecomeActive:
2018-07-11 12:58:48 +0000: applicationWillResignActive:
2018-07-11 12:58:48 +0000: applicationDidEnterBackground:

I am at a loss as to how to further investigate this.

Thanks Ants


Hi @Ants,

Calls to glGen are only ever made when a ShinobiChart view is being created or drawn, so I think you must be using a chart somewhere in order to see this crash.

In your other app you mention monitoring for applicationWillResignActive: does this mean that you’re not using the method directly? If so then it’s possible that between the application becoming inactive and the calls to flushPendingGLOperations and setIsEnteringBackground:YES, the chart is attempting to update its canvas, which it is unable to do in the background.

Unfortunately without more information about what is happening in your app at the point of the crash, we’re struggling to know what’s going on. Perhaps you could add in some debugging in the SChartDelegate methods -sChartRenderStarted:withFullRedraw:, -sChartRenderFinished:, -sChartWillStartLoadingData: and -sChartDidFinishLoadingData: to help work out what the chart is attempting to do at the point of the crash?

Kind regards,