Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton CommonFunctionality.PurchasesSwiftType is neither public nor identical to Purchases.shared #1233

Open
10 of 11 tasks
importRyan opened this issue Dec 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@importRyan
Copy link

This prohibits seamless SDK usage from both Flutter and Swift in purchases_flutter: ^8.4.0.

  • If only Dart runs configure, Swift's Purchases.shared must be configured separately or crash.
  • If only Swift runs configure before purchases-flutter is configured in Dart, the Dart-side SDK calls will crash as below.
  • If both Dart and Swift run configure, a warning about multiple instances is emitted INFO: ℹ️ Purchases instance already set. Did you mean to configure two Purchases objects? and redundant requests will fire (likely in an app's crowded early lifecycle).

Possible resolutions
(a) Publicly expose PurchasesHybridCommon's .shared instance for usage from Swift
or (b) Have PurchasesHybridCommon adopt Purchases.shared as its standard instance

While the code paths are obvious, here's an example stack trace from a Swift-configured-.shared-before-Dart accesses its "shared" instance. Before the trace, the Swift-side Purchases SDK successfully finished network requests. After the crash, (lldb) po Purchases.isConfigured returns true as expected.

Thread 1: Fatal error: Purchases has not been configured. Please configure the SDK before calling this method
Thread 1 Queue : com.apple.main-thread (serial)
#0	0x000000018fdb5978 in _swift_runtime_on_report ()
#1	0x000000018fe91f04 in _swift_stdlib_reportFatalErrorInFile ()
#2	0x000000018fa21bdc in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never ()
#3	0x000000018fa20e24 in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never ()
#4	0x0000000105101f50 in closure #1 in variable initialization expression of static FatalErrorUtil.defaultFatalErrorClosure at /Users/ryan/Developer/macrofactor/apps/sbs_diet_app/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/FatalErrorUtil.swift:15
#5	0x000000010510216c in fatalError(_:file:line:) at /Users/ryan/Developer/macrofactor/apps/sbs_diet_app/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/FatalErrorUtil.swift:27
#6	0x00000001050e80fc in static CommonFunctionality.sharedInstance.getter at /Users/ryan/Developer/macrofactor/apps/sbs_diet_app/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/CommonFunctionality.swift:21
#7	0x00000001050ee840 in static CommonFunctionality.logIn(appUserID:completion:) at /Users/ryan/Developer/macrofactor/apps/sbs_diet_app/ios/Pods/PurchasesHybridCommon/ios/PurchasesHybridCommon/PurchasesHybridCommon/CommonFunctionality.swift:358
#8	0x00000001050eee24 in @objc static CommonFunctionality.logIn(appUserID:completion:) ()
#9	0x0000000105847b7c in -[PurchasesFlutterPlugin logInAppUserID:result:] at /Users/ryan/.pub-cache/hosted/pub.dev/purchases_flutter-8.4.0/ios/Classes/PurchasesFlutterPlugin.m:357
#10	0x0000000105844c94 in -[PurchasesFlutterPlugin handleMethodCall:result:] at /Users/ryan/.pub-cache/hosted/pub.dev/purchases_flutter-8.4.0/ios/Classes/PurchasesFlutterPlugin.m:94
#11	0x00000001245ee82c in __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke ()
#12	0x00000001240686b8 in invocation function for block in flutter::PlatformMessageHandlerIos::HandlePlatformMessage(std::_fl::unique_ptr<flutter::PlatformMessage, std::_fl::default_delete<flutter::PlatformMessage>>) ()
#13	0x0000000107dfc88c in _dispatch_call_block_and_release ()
#14	0x0000000107dfe578 in _dispatch_client_callout ()
#15	0x0000000107e0edfc in _dispatch_main_queue_drain ()
#16	0x0000000107e0e9b4 in _dispatch_main_queue_callback_4CF ()
#17	0x0000000191475bbc in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#18	0x00000001914721b0 in __CFRunLoopRun ()
#19	0x00000001914c4274 in CFRunLoopRunSpecific ()
#20	0x00000001de63d4c0 in GSEventRunModal ()
#21	0x000000019400a77c in -[UIApplication _run] ()
#22	0x0000000193c30e64 in UIApplicationMain ()
#23	0x000000019436da7c in ___lldb_unnamed_symbol289315 ()
#24	0x0000000108c56c84 in static UIApplicationDelegate.main() ()
#25	0x0000000108c56bfc in static AppDelegate.$main() ()
#26	0x0000000108c592e4 in main at /Users/ryan/Developer/macrofactor/apps/sbs_diet_app/ios/Runner/AppDelegate.swift:13
#27	0x00000001b7698de8 in start ()
Enqueued from com.apple.root.default-qos.overcommit (Thread 11) Queue : com.apple.root.default-qos.overcommit (serial)
#0	0x0000000107e031f0 in dispatch_async ()
#1	0x00000001240682bc in flutter::PlatformMessageHandlerIos::HandlePlatformMessage ()
#2	0x00000001245d775c in flutter::Shell::OnEngineHandlePlatformMessage ()
#3	0x00000001245b978c in flutter::Engine::HandlePlatformMessage ()
#4	0x00000001240f72f4 in flutter::RuntimeController::HandlePlatformMessage ()
#5	0x00000001244eb86c in flutter::UIDartState::HandlePlatformMessage ()
#6	0x00000001244ec7f0 in flutter::(anonymous namespace)::HandlePlatformMessage ()
#7	0x00000001244bc150 in tonic::FfiDispatcher<void, _Dart_Handle* (*)(std::_fl::basic_string<char, std::_fl::char_traits<char>, std::_fl::allocator<char>> const&, _Dart_Handle*, _Dart_Handle*), &flutter::PlatformConfigurationNativeApi::SendPlatformMessage(std::_fl::basic_string<char, std::_fl::char_traits<char>, std::_fl::allocator<char>> const&, _Dart_Handle*, _Dart_Handle*)>::Call ()
#8	0x0000000126d880e8 in 0x126d880e8 ()
#9	0x0000000132b71af4 in 0x132b71af4 ()
#10	0x0000000132b71948 in 0x132b71948 ()
#11	0x0000000132b71828 in 0x132b71828 ()
#12	0x0000000132b71418 in 0x132b71418 ()
#13	0x0000000132b7128c in 0x132b7128c ()
#14	0x0000000132b69b54 in 0x132b69b54 ()
#15	0x000000014814f1a4 in 0x14814f1a4 ()
#16	0x000000015260dba0 in 0x15260dba0 ()
#17	0x000000015260cff4 in 0x15260cff4 ()
#18	0x000000014813beec in 0x14813beec ()
#19	0x000000014813bd28 in 0x14813bd28 ()
#20	0x000000014813cb38 in 0x14813cb38 ()
#21	0x000000014813c718 in 0x14813c718 ()
#22	0x0000000148101888 in 0x148101888 ()
#23	0x0000000148100360 in 0x148100360 ()
#24	0x0000000132b7434c in 0x132b7434c ()
#25	0x0000000126d8d460 in 0x126d8d460 ()
#26	0x000000014813beec in 0x14813beec ()
#27	0x000000014813bd28 in 0x14813bd28 ()
#28	0x000000014813cb38 in 0x14813cb38 ()
#29	0x000000014813c718 in 0x14813c718 ()
#30	0x0000000148101888 in 0x148101888 ()
#31	0x0000000148100360 in 0x148100360 ()
#32	0x0000000132b7434c in 0x132b7434c ()
#33	0x0000000126d8d460 in 0x126d8d460 ()
#34	0x000000014813beec in 0x14813beec ()
#35	0x000000014813bd28 in 0x14813bd28 ()
#36	0x000000014813cb38 in 0x14813cb38 ()
#37	0x000000014813c718 in 0x14813c718 ()
#38	0x0000000148101888 in 0x148101888 ()
#39	0x0000000148100360 in 0x148100360 ()
#40	0x000000014813e5f0 in 0x14813e5f0 ()
#41	0x00000001481364bc in 0x1481364bc ()
#42	0x0000000148136020 in 0x148136020 ()
#43	0x0000000148135f08 in 0x148135f08 ()
#44	0x0000000126d83af4 in 0x126d83af4 ()
#45	0x0000000124661a80 in dart::DartEntry::InvokeFunction ()
#46	0x0000000124a5b2ec in Dart_InvokeClosure ()
#47	0x00000001245b1d34 in tonic::DartMicrotaskQueue::RunMicrotasks ()
#48	0x0000000124087b00 in fml::MessageLoopImpl::FlushTasks ()
#49	0x000000012408bac4 in fml::MessageLoopDarwin::OnTimerFire ()
#50	0x00000001914ec28c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#51	0x00000001914ebf30 in __CFRunLoopDoTimer ()
#52	0x00000001914eba84 in __CFRunLoopDoTimers ()
#53	0x0000000191472124 in __CFRunLoopRun ()
#54	0x00000001914c4274 in CFRunLoopRunSpecific ()
#55	0x000000012408bbb0 in fml::MessageLoopDarwin::Run ()
#56	0x000000012408acb0 in std::_fl::__function::__func<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0, std::_fl::allocator<fml::Thread::Thread(std::_fl::function<void (fml::Thread::ThreadConfig const&)> const&, fml::Thread::ThreadConfig const&)::$_0>, void ()>::operator() ()
#57	0x000000012408a9c0 in fml::ThreadHandle::ThreadHandle(std::_fl::function<void ()>&&)::$_0::__invoke(void*) ()
#58	0x000000021c0697d0 in _pthread_start ()
#59	0x000000021c069480 in thread_start ()

‼️ Required data ‼️

Do not remove any of the steps from the template below. If a step is not applicable to your issue, please leave that step empty.

There are a lot of things that can contribute to things not working. Having a very basic understanding of your environment will help us understand your issue faster!

Environment

  • Output of flutter doctor
  • Version of purchases-flutter
  • Testing device version e.g.: iOS 15.5, Android API 30, etc.
  • How often the issue occurs- every one of your customers is impacted? Only in dev?
  • Debug logs that reproduce the issue
  • Steps to reproduce, with a description of expected vs. actual behavior
    Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Describe the bug

A clear and concise description of what the bug is. The more detail you can provide the faster our team will be able to triage and resolve the issue.

Additional context

Add any other context about the problem here.

@importRyan importRyan added the bug Something isn't working label Dec 30, 2024
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@JulianPscheid
Copy link

I'm seeing app crashes in Google Play due to this issue. I'm going to roll back to 8.3.0 for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants