bugsnag / bugsnag-cocoa-performance

Monitor the start-up, screen loading and network requests of your iOS app and see the results in your BugSnag dashboard.
https://docs.bugsnag.com/performance/integration-guides/ios
MIT License
10 stars 7 forks source link

[PLAT-12192] Catch badly behaved Apple APIs and report any errors generated rather than crashing #267

Closed kstenerud closed 3 months ago

kstenerud commented 3 months ago

Goal

Apple breaks their own NSURLSessionTask APIs by throwing exceptions to mark them as unsupported, so we must work around this or else we'll crash.

Design

Affected APIs are now guarded with try/catch, and a new attribute field bugsnag.instrumentation_message has been added to allow reporting the error to the backend.

Because the request can't be fetched from an AVAssetDownloadTask, it never goes through a metrics collection phase either, meaning that we can only rely upon the destructor for closing the span. This behaviour can be triggered by calling endOnDestroy on the span (which we now do whenever we fail to fetch a request from a task).

I've also added some permanent trace and debug logging because I got tired of adding it every time something breaks :P

Testing

New e2e tests that check using AVAssetDownloadTask.

github-actions[bot] commented 3 months ago

BugsnagPerformance.framework binary size increased by 17,896 bytes from 459,464 to 477,360

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +19% +6.83Ki   +19% +6.83Ki    [__TEXT]
  +4.1% +4.24Ki  +4.1% +4.24Ki    __TEXT,__text
   +69% +4.04Ki   +69% +4.04Ki    __TEXT,__cstring
   +24% +1.78Ki   +24% +1.78Ki    __DATA_CONST,__cfstring
  +0.9%    +848  +0.9%    +848    Symbol Table
  +0.6%    +656  +0.6%    +656    String Table
  +6.8%    +644  +6.8%    +644    __TEXT,__gcc_except_tab
  +3.5%    +160  +3.5%    +160    __TEXT,__unwind_info
  +0.7%     +64  +0.7%     +64    __TEXT,__objc_stubs
  +0.7%     +24  +0.7%     +24    Lazy Binding Info
  +0.2%     +24  +0.2%     +24    __DATA,__objc_const
  +0.6%     +16  +0.6%     +16    __DATA,__objc_selrefs
  +0.1%     +13  +0.1%     +13    __TEXT,__objc_methname
  +0.8%     +12  +0.8%     +12    __TEXT,__stub_helper
  +0.8%     +12  +0.8%     +12    __TEXT,__stubs
  +0.8%      +8  +0.8%      +8    Function Start Addresses
  +0.2%      +4  +0.2%      +4    [3 Others]
  -0.7%     -24  -0.7%     -24    Binding Info
  -0.3%     -48  -0.3%     -48    [__DATA]
  [DEL]      -4  -9.7% -1.48Ki    [__LINKEDIT]
 -53.8% -1.77Ki -53.8% -1.77Ki    [__DATA_CONST]
  +3.9% +17.5Ki  +3.4% +16.0Ki    TOTAL

Generated by :no_entry_sign: Danger