refiner-io / mobile-sdk-flutter

https://refiner.io
Apache License 2.0
1 stars 0 forks source link

[iOS] Crash when resetUser is called #2

Closed kuznetsov-from-wonderland closed 7 months ago

kuznetsov-from-wonderland commented 7 months ago

Hey πŸ‘‹πŸ»

Flutter doctor output

fvm flutter doctor -v
[βœ“] Flutter (Channel stable, 3.13.5, on macOS 14.0 23A344 darwin-arm64, locale en-GE)
    β€’ Flutter version 3.13.5 on channel stable at /Users/kuznetsov.one/fvm/versions/3.13.5
    β€’ Upstream repository https://github.com/flutter/flutter.git
    β€’ Framework revision 12fccda598 (8 weeks ago), 2023-09-19 13:56:11 -0700
    β€’ Engine revision bd986c5ed2
    β€’ Dart version 3.1.2
    β€’ DevTools version 2.25.0

[βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    β€’ Android SDK at /Users/kuznetsov.one/Library/Android/sdk
    β€’ Platform android-34, build-tools 33.0.1
    β€’ ANDROID_HOME = /Users/kuznetsov.one/Library/Android/sdk
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Build 15A507
    β€’ CocoaPods version 1.13.0

[βœ“] Android Studio (version 2022.1)
    β€’ 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.15+0-b2043.56-8887301)

[βœ“] VS Code (version 1.81.1)
    β€’ VS Code at /Applications/Visual Studio Code.app/Contents
    β€’ Flutter extension version 3.76.0

[βœ“] Connected device (2 available)
    β€’ iPhone 15 Pro Max (mobile) β€’ 1BDF2997-3334-48DB-AE50-45A157AFEBF2 β€’ ios          β€’ com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    β€’ macOS (desktop)            β€’ macos                                β€’ darwin-arm64 β€’ macOS 14.0 23A344 darwin-arm64

[βœ“] Network resources
    β€’ All expected network resources are available.

β€’ No issues found!

Versions CleanShot 2023-11-16 at 11 03 47@2x

Crash report CleanShot 2023-11-16 at 11 00 57@2x

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Incident Identifier: 866C2CBE-24EC-4ECE-9928-451FFDE043B4
CrashReporter Key:   FB9022BF-A0FA-6F36-F384-62B9F7D3B6D8
Hardware Model:      MacBookPro18,1
Process:             Runner [13733]
Path:                /Users/USER/Library/Developer/CoreSimulator/Devices/1BDF2997-3334-48DB-AE50-45A157AFEBF2/data/Containers/Bundle/Application/DE47849C-FCBA-4234-AB69-125B8ECC2C1A/Runner.app/Runner
Identifier:          app.tabby.merchant.dev
Version:             2.1.7 (144)
Code Type:           X86-64 (Native)
Role:                Foreground
Parent Process:      launchd_sim [4128]
Coalition:           com.apple.CoreSimulator.SimDevice.1BDF2997-3334-48DB-AE50-45A157AFEBF2 [29385]
Responsible Process: SimulatorTrampoline [1366]

Date/Time:           2023-11-16 10:59:19.8735 +0400
Launch Time:         2023-11-16 10:56:35.5328 +0400
OS Version:          macOS 14.0 (23A344)
Release Type:        User
Report Version:      104

Exception Type:  EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Termination Reason: SIGNAL 4 Illegal instruction: 4
Terminating Process: exc handler [13733]

Triggered by Thread:  0

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   ???                                    0x10803e748 ???
1   Runner                                 0x1030da54e specialized RefinerFlutterPlugin.handle(_:result:) + 14 [inlined]
2   Runner                                 0x1030da54e @objc RefinerFlutterPlugin.handle(_:result:) + 78 (<compiler-generated>:15)
3   Flutter                                0x11f3329bd __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 168
4   Flutter                                0x11ecf4f52 invocation function for block in flutter::PlatformMessageHandlerIos::HandlePlatformMessage(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::PlatformMessage, std::_LIBCPP_ABI_NAMESPACE::default_delete<flutter::PlatformMessage>>) + 94
5   libdispatch.dylib                      0x1119eea90 _dispatch_call_block_and_release + 12
6   libdispatch.dylib                      0x1119efd3a _dispatch_client_callout + 8
7   libdispatch.dylib                      0x1119feac0 _dispatch_main_queue_drain + 1420
8   libdispatch.dylib                      0x1119fe526 _dispatch_main_queue_callback_4CF + 31
9   CoreFoundation                         0x112c31850 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
10  CoreFoundation                         0x112c2c18b __CFRunLoopRun + 2463
11  CoreFoundation                         0x112c2b409 CFRunLoopRunSpecific + 557
12  GraphicsServices                       0x118201187 GSEventRunModal + 137
13  UIKitCore                              0x1344b93a2 -[UIApplication _run] + 972
14  UIKitCore                              0x1344bde10 UIApplicationMain + 123
15  Runner                                 0x102b0a46f main + 63 (AppDelegate.swift:5)
16  dyld_sim                               0x10bf023ee start_sim + 10
17  dyld                                   0x20360c3a6 start + 1942

Thread 1:: com.apple.rosetta.exceptionserver
0   ???                                 0x7ff7ffe492b4 ???

Thread 2:: GC Timer thread
0   ???                                    0x1035efa78 ???
1   ???                                    0x1039a477c ???
2   libsystem_pthread.dylib                0x1128c576b _pthread_cond_wait + 1211
3   libc++.1.dylib                         0x10cae806b std::__1::condition_variable::__do_timed_wait(std::__1::unique_lock<std::__1::mutex>&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l>>>) + 93
4   RefinerInternalSDK                     0x110ebd6d1 void kotlin::RepeatedTimer<kotlin::steady_clock>::Run<kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, std::__1::function<long long ()>)::'lambda'()>(kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, std::__1::function<long long ()>)::'lambda'()&&) + 241
5   RefinerInternalSDK                     0x110ebd96f void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (*)(kotlin::ScopedThread::attributes, void (kotlin::RepeatedTimer<kotlin::steady_clock>::*&&)(kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, std::__1::function<long long ()>)::'lambda'()&&) noexcept, kotlin::RepeatedTimer<kotlin::steady_clock>*&&, kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, std::__1::function<long long ()>)::'lambda'()&&), kotlin::ScopedThread::attributes, void (kotlin::RepeatedTimer<kotlin::steady_clock>::*)(kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, std::__1::function<long long ()>)::'lambda'()&&) noexcept, kotlin::RepeatedTimer<kotlin::steady_clock>*, kotlin::gcScheduler::internal::GCSchedulerDataAdaptive<kotlin::steady_clock>::GCSchedulerDataAdaptive(kotlin::gcScheduler::GCSchedulerConfig&, std::__1::function<long long ()>)::'lambda'()>>(void*) + 127
6   libsystem_pthread.dylib                0x1128c5202 _pthread_start + 99
7   libsystem_pthread.dylib                0x1128c0bab thread_start + 15

Thread 3:: Main GC thread
0   ???                                    0x1035efa78 ???
1   ???                                    0x1039a477c ???
2   libsystem_pthread.dylib                0x1128c576b _pthread_cond_wait + 1211
3   libc++.1.dylib                         0x10cae7fe2 std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 18
4   RefinerInternalSDK                     0x110ec156b std::__1::invoke_result<kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1>::type kotlin::ScopedThread::Run<kotlin::ScopedThread (anonymous namespace)::createGCThread<kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1>(char const*, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1&&)::'lambda'()>(kotlin::ScopedThread::attributes, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1&&) + 459
5   RefinerInternalSDK                     0x110ec39e7 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (*)(kotlin::ScopedThread::attributes, kotlin::ScopedThread (anonymous namespace)::createGCThread<kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1>(char const*, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1&&)::'lambda'()&&), kotlin::ScopedThread::attributes, kotlin::ScopedThread (anonymous namespace)::createGCThread<kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1>(char const*, kotlin::gc::ConcurrentMarkAndSweep::ConcurrentMarkAndSweep(kotlin::gcScheduler::GCScheduler&, bool, unsigned long)::$_1&&)::'lambda'()>>(void*) + 119
6   libsystem_pthread.dylib                0x1128c5202 _pthread_start + 99
7   libsystem_pthread.dylib                0x1128c0bab thread_start + 15

...
kuznetsov-from-wonderland commented 7 months ago

@chezmo @tekinalper @maliaydemir hey Refiner team. Could you please take a look at this issue?

ktnishide commented 7 months ago

same here

tekinalper commented 7 months ago

@kuznetsov-from-wonderland @ktnishide We're checking it and will release a hotfix asap.

tekinalper commented 7 months ago

@kuznetsov-from-wonderland @ktnishide We've released version 0.0.4. Could you please test it and let us know if everything is alright?

kuznetsov-from-wonderland commented 7 months ago
Swift Compiler Error (Xcode): Incorrect argument label in call (have 'projectId:enableDebugMode:', expected 'projectId:debugMode:')
/Users/kuznetsov.one/.pub-cache/hosted/pub.dev/refiner_flutter-0.0.4/ios/Classes/RefinerFlutterPlugin.swift:48:35

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

CleanShot 2023-11-17 at 12 25 18@2x

There's anothe issue arised. I monkey patched source code and it worked.

    public func initialize(projectId:String, enableDebugMode:Bool) {
        Refiner.instance.initialize(projectId: projectId, debugMode: enableDebugMode)
        registerCallbacks()
    }

I have RefinerSDK (1.3.0) in my Podfile.lock.

Sad to see, but did you run your plugin code?

kuznetsov-from-wonderland commented 7 months ago

I didn't notice any new crashes on 0.0.4, so thank you! But there are two more issues regarding SDK usage.

1️⃣ I log in with a user --> I call

    await Refiner.identifyUser(
      userId: user.id,
      userTraits: {},
      locale: user.lang.name,
    );
  }

The form is shown to a user based on the screen name NewOrderRoute βœ…

Then I log out, I call Refiner.resetUser() and log in with a different user. Then I call identify again with the new userId. I go to

NewOrderRoute again, I do expect the it will display the Survey, but the form is not ❗️ displayed to a new user.

2️⃣ How to properly pass down the locale? I have English and Arabic in my project. I pass 'ar' and 'en' as String to Refiner.identifyUser method call, but on the Refiner.io dashboard when I go and check user traits, the locale is not saved anywhere there. How to make refiner SDK v 0.0.4 respect the locale correcyly?

  Future<void> identify(AnalyticsUser user) async {
    await Refiner.identifyUser(
      userId: user.id,
      userTraits: {},
      locale: user.lang.name,
    );
  }
chezmo commented 7 months ago

@kuznetsov-from-wonderland

Regarding 1/ The scenario you describe should work. We are currently trying to reproduce the issue. Can you send us the user IDs you are using to our support channel at contact@refiner.io please?

Regarding 2/ If you want to attach the locale to the user for further segmentation, you'll need to add it to the userTraits object. The locale parameter is solely used for showing the survey in the right language.

kuznetsov-from-wonderland commented 7 months ago

@kuznetsov-from-wonderland

Regarding 1/ The scenario you describe should work. We are currently trying to reproduce the issue. Can you send us the user IDs you are using to our support channel at contact@refiner.io please?

Regarding 2/ If you want to attach the locale to the user for further segmentation, you'll need to add it to the userTraits object. The locale parameter is solely used for showing the survey in the right language.

On it. Will try today. Thank you!

kuznetsov-from-wonderland commented 7 months ago

I passed down the locale property to the userTraits and checked it's recognized in dashboard. image

And I can confirm that it doesn't work CleanShot 2023-11-21 at 09 36 57@2x

I asked for a debug session by emailing you on contact@refiner.io

Please respond.

kuznetsov-from-wonderland commented 7 months ago

βœ… Resolved in 0.0.5

Thank you!