title: CGContextSaveGState: invalid context 0x0 at App Launch
body: <p>I have set <code>CG_CONTEXT_SHOW_BACKTRACE</code> environnement variable to <code>YES</code> because I had a the following error <code>CGContextSaveGState: invalid context 0x0</code>.</p>
  
  <p>The following stacktrace didn't help me much. </p>
  
  <pre><code>&lt;Error&gt;: CGContextSaveGState: invalid context 0x0. Backtrace:
        &lt;-[UIStatusBarBatteryItemView contentsImage]+773&gt;
         &lt;-[UIStatusBarItemView updateContentsAndWidth]+36&gt;
          &lt;-[UIStatusBarItemView initWithItem:data:actions:style:]+503&gt;
           &lt;+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:]+159&gt;
            &lt;-[UIStatusBarLayoutManager _createViewForItem:withData:actions:]+168&gt;
             &lt;-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:]+3
              &lt;-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:]+108&gt;
               &lt;-[UIStatusBarForegroundView _setStatusBarData:actions:animated:]+951&gt;
                &lt;-[UIStatusBarForegroundView setStatusBarData:actions:animated:]+874&gt;
                 &lt;__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke+443&gt;
                  &lt;+[UIView(Animation) performWithoutAnimation:]+82&gt;
                   &lt;-[UIStatusBar _prepareToSetStyle:animation:forced:]+935&gt;
                    &lt;-[UIStatusBar _requestStyleAttributes:animationParameters:forced:]+404&gt;
                     &lt;-[UIStatusBar requestStyle:animationParameters:forced:]+490&gt;
                      &lt;-[UIStatusBar requestStyle:animated:forced:]+113&gt;
                       &lt;-[UIStatusBar forceUpdateStyleOverrides:]+97&gt;
                        &lt;-[UIStatusBar _evaluateServerRegistration]+294&gt;
                         &lt;-[UIStatusBar didMoveToSuperview]+33&gt;
                          &lt;__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke+683&gt;
                           &lt;-[UIView(Hierarchy) _postMovedFromSuperview:]+484&gt;
                            &lt;-[UIView(Internal) _addSubview:positioned:relativeTo:]+2305&gt;
                             &lt;-[UIView(Hierarchy) addSubview:]+56&gt;
                              &lt;-[UIStatusBarWindow setStatusBar:]+311&gt;
                               &lt;-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:]+384&gt;
                                &lt;-[UIApplication _runWithMainScene:transitionContext:completion:]+1047&gt;
                                 &lt;__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invo
                                  &lt;-[UIApplication workspaceDidEndTransaction:]+163&gt;
                                   &lt;__37-[FBSWorkspace clientEndTransaction:]_block_invoke_2+71&gt;
                                    &lt;__40-[FBSWorkspace _performDelegateCallOut:]_block_invoke+54&gt;
                                     &lt;-[FBSSerialQueue _performNext]+184&gt;
                                      &lt;-[FBSSerialQueue _performNextFromRunLoopSource]+52&gt;
                                       &lt;FBSSerialQueueRunLoopSourceHandler+33&gt;
                                        &lt;__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+15&gt;
                                         &lt;__CFRunLoopDoSources0+523&gt;
                                          &lt;__CFRunLoopRun+1032&gt;
                                           &lt;CFRunLoopRunSpecific+470&gt;
                                            &lt;CFRunLoopRunInMode+123&gt;
                                             &lt;-[UIApplication _run]+540&gt;
                                              &lt;UIApplicationMain+160&gt;
                                               &lt;main+94&gt;
  </code></pre>
  
  <p>The error is happening at launch and there seems to be a problem with the Battery view. Does this error ring any bell to you ? </p>
  
  <p>FWW my app is mostly written in Swift 2.0, on iOS9 with Xcode 7b6. </p>