Skip to content

[in_app_purchase_storekit] The plugin should not crash when [[NSBundle mainBundle] appStoreReceiptURL] is nil #117842

@sneglia9191

Description

@sneglia9191

I am getting a hard crash when purchasing a non-consumable on IOS simulators with 14.X. It does not crash on a simulator with 16.2. It also works in the sandbox environment on a physical device running 14.8.1

The crash occurs on this exact line:

productDetails.launchPurchaseFlowSuccess =
        await _iap?.buyNonConsumable(purchaseParam: purchaseParam) ?? false;

The billing Apple Pay dialog still appears and I am able to complete the billing transaction, but the app has crashed. The error is:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSPlaceholderData initWithContentsOfURL:options:maxLength:error:

The full error dump is

2022-12-31 13:00:38.558115-0500 Runner[4880:31777] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSPlaceholderData initWithContentsOfURL:options:maxLength:error:]: nil URL argument'
 *** First throw call stack:
 (
 	0   CoreFoundation                      0x00007fff20420af6 __exceptionPreprocess + 242
 	1   libobjc.A.dylib                     0x00007fff20177e78 objc_exception_throw + 48
 	2   Foundation                          0x00007fff20751939 -[NSData(NSData) initWithContentsOfFile:options:error:] + 0
 	3   Foundation                          0x00007fff207512ff +[NSData(NSData) dataWithContentsOfURL:options:error:] + 49
 	4   in_app_purchase_storekit            0x000000010dad0830 -[FIAPReceiptManager getReceiptData:error:] + 96
 	5   in_app_purchase_storekit            0x000000010dad05f6 -[FIAPReceiptManager retrieveReceiptWithError:] + 134
 	6   in_app_purchase_storekit            0x000000010dad46c6 -[InAppPurchasePlugin retrieveReceiptData:result:] + 134
 	7   in_app_purchase_storekit            0x000000010dad2037 -[InAppPurchasePlugin handleMethodCall:result:] + 983
 	8   Flutter                             0x000000010e1741f5 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 104
 	9   Flutter                             0x000000010dbac18a ___ZN7flutter25PlatformMessageHandlerIos21HandlePlatformMessageENSt3__110unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE_block_invoke + 86
 	10  libdispatch.dylib                   0x00000001110967ec _dispatch_call_block_and_release + 12
 	11  libdispatch.dylib                   0x00000001110979c8 _dispatch_client_callout + 8
 	12  libdispatch.dylib                   0x00000001110a5e75 _dispatch_main_queue_callback_4CF + 1152
 	13  CoreFoundation                      0x00007fff2038edbb __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
 	14  CoreFoundation                      0x00007fff2038963e __CFRunLoopRun + 2685
 	15  CoreFoundation                      0x00007fff203886d6 CFRunLoopRunSpecific + 567
 	16  GraphicsServices                    0x00007fff2bededb3 GSEventRunModal + 139
 	17  UIKitCore                           0x00007fff24690e0b -[UIApplication _run] + 912
 	18  UIKitCore                           0x00007fff24695cbc UIApplicationMain + 101
 	19  Runner                              0x0000000104a89ccf main + 63
 	20  ???                                 0x00000002050eb310 0x0 + 8674784016
 )
libc++abi.dylib: terminating with uncaught exception of type NSException
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSPlaceholderData initWithContentsOfURL:options:maxLength:error:]: nil URL argument'
terminating with uncaught exception of type NSException
 CoreSimulator 857.14 - Device: iPhone 12 Pro Max (6D7FF6C5-3809-4475-AEC2-5C49B4B139FC) - Runtime: iOS 14.3 (18C61) - DeviceType: iPhone 12 Pro Max
 _LSContextInitReturningError() failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0x06fa6496 daaf0574 96588f97 3218198d ... 2862792f 88b4164f }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x2bded6e0 32f2e4de 89d64fa6 5f014c96 ... b204c4d8 0350c8ce }}

Plugins

in_app_purchase: ^3.0.8
in_app_purchase_android: ^0.2.3+6
in_app_purchase_storekit: ^0.3.3

Steps to Reproduce

To reproduce, simply start an IOS emulator running version 14.3. Initiate a billing transaction of a non-consumable.

flutter doctor
Flutter (Channel stable, 3.3.9, on macOS 13.1 22C65 darwin-arm, locale en-GB)
    • Flutter version 3.3.9 on channel stable at /Users/sneglia/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (6 weeks ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/sneglia/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] Connected device (2 available)
    • iPhone 12 Pro Max (mobile) • 6D7FF6C5-3809-4475-AEC2-5C49B4B139FC • ios          • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64 • macOS 13.1 22C65 darwin-arm

[✓] HTTP Host Availability
    • All required HTTP hosts are available

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolee: device-specificOnly manifests on certain devicesp: in_app_purchasePlugin for in-app purchasepackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions