Skip to content

fix: properly handle exceptions in the native sdks #155

@thekorn

Description

@thekorn

there are cases where the native xandr sdk is raising exceptions. This should never crash, but be propagated to the flutter stack as a proper error.

Sample situations:

  • when using a network level (read DNS) level ad blocking, the xandr iOS sdk is crashing with the error below
 APPNEXUS ERROR  -[XandrAd fetchMemberIdList]_block_invoke -- XandrAd Init - Fetching Viewable Impression Member Id's Failed
The Flutter DevTools debugger and profiler on iPhone 15 Pro Max is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:52158/XBQcJRtE67A=/
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(Error Domain=XandrAd.sharedInstance().initWithMemberID Code=1 "(null)", NSError, Stacktrace: ["0   Runner
       0x00000001002e75d4 $s9xandr_ios9wrapError33_F94AE7A8B8507C28D15D12FDC0FE2E87LLySayypSgGypF + 1708", "1   Runner                              0x00000001002ec178 $s9xandr_ios17XandrHostApiSetupC5setUp15binaryMesse
nger3api20messageChannelSuffixySo013FlutterBinaryJ0_p_AA0cdE0_pSgSStFZyypSg_yAKctcfU_ys6ResultOySbs5Error_pGcfU_ + 376", "2   Runner                              0x00000001002f68d4 $s9xandr_ios11XandrPluginC04initC3Sdk
8memberId09publisherH08testMode10completionys5Int64V_AJSgSbys6ResultOySbs5Error_pGctFyyScMYccfU_ySbcfU_ + 1988", "3   Runner                              0x00000001002f6990 $sSbIegy_SbIeyBy_TR + 60", "4   Runner
                       0x00000001002d6bf4 __69-[XandrAd initWithMemberID:preCacheRequestObjects:completionHandler:]_block_invoke_2 + 124", "5  <…>
  • in contrast, the android side seems to handle this much more easily
D/Xandr.BannerView( 6132): >>> Ad Request failed, AdView:p0=de.thekorn.xandr.models.ads.BannerAd{cb4ecaa V.E...... ........ 0,0-1440,315} ResultCode:p1=com.appnexus.opensdk.ResultCode@ea0c09b
D/Xandr.BannerView( 6132): >>> Ad Request failed, AdView:p0=de.thekorn.xandr.models.ads.BannerAd{8036c38 V.E...... ........ 0,0-315,315} ResultCode:p1=com.appnexus.opensdk.ResultCode@fbe5411
E/OPENSDK-REQUEST( 6132): E203: Ad couldn't be fetched due to io error, probably http related.
E/OPENSDK ( 6132): E203: Ad couldn't be fetched due to io error, probably http related.
D/Xandr.BannerView( 6132): >>> Ad Request failed, AdView:p0=de.thekorn.xandr.models.ads.BannerAd{7cd2976 V.E...... ........ 0,0-4,4} ResultCode:p1=com.appnexus.opensdk.ResultCode@c40cb77
D/TrafficStats( 6132): tagSocket(209) with statsTag=0xffffffff, statsUid=-1
E/OPENSDK-REQUEST( 6132): E203: Ad couldn't be fetched due to io error, probably http related.
E/OPENSDK ( 6132): E203: Ad couldn't be fetched due to io error, probably http related.
D/Xandr.BannerView( 6132): >>> Ad Request failed, AdView:p0=de.thekorn.xandr.models.ads.BannerAd{423204d V.E...... ........ 0,0-1050,875} ResultCode:p1=com.appnexus.opensdk.ResultCode@f5a6702
  • besides specific error handlers we should in general also handle the case of a "PlatformException" much more gracefully

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions