firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

πŸ› [firebase_auth] Crash on ios when signing out #9972

Closed mhamTech closed 1 year ago

mhamTech commented 1 year ago

Application keep crashing on IOS devices when signOut method invoked, even with try catch.

Also, there is no log printed for debugging !!

firebase_core: ^2.3.0 firebase_auth: ^4.1.3

flutter doctor -v:

[βœ“] Flutter (Channel stable, 3.3.8, on macOS 13.0.1 22A400 darwin-x64, locale en-SA) β€’ Flutter version 3.3.8 on channel stable at /Users/user/Developer/flutter β€’ Upstream repository https://github.com/flutter/flutter.git β€’ Framework revision 52b3dc25f6 (13 days ago), 2022-11-09 12:09:26 +0800 β€’ Engine revision 857bd6b74c β€’ Dart version 2.18.4 β€’ DevTools version 2.15.0

[βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.0) β€’ Android SDK at /Users/user/Library/Android/sdk β€’ Platform android-33, build-tools 33.0.0 β€’ 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.1) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ Build 14B47b β€’ CocoaPods version 1.11.3

[βœ“] Chrome - develop for the web β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[βœ“] 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)

[βœ“] VS Code (version 1.73.1) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension can be installed from: πŸ”¨ https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[βœ“] Connected device (4 available) β€’ sdk gphone64 x86 64 (mobile) β€’ emulator-5554 β€’ android-x64 β€’ Android 12 (API 31) (emulator) β€’ iPhone 14 Pro Max (mobile) β€’ 20A9826D-A0E1-4C4B-BD9A-CB37073E7978 β€’ ios β€’ com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator) β€’ macOS (desktop) β€’ macos β€’ darwin-x64 β€’ macOS 13.0.1 22A400 darwin-x64 β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 107.0.5304.110

[βœ“] HTTP Host Availability β€’ All required HTTP hosts are available

β€’ No issues found!

darshankawar commented 1 year ago

@mhamTech I used the plugin example with latest versions as you mentioned above and ran it on iOS device, used google sign in and then signed out which worked properly as below without throwing any crash or error.

https://user-images.githubusercontent.com/67046386/203319397-1386bba3-ee0c-4b11-98e5-d9c947cf80df.MP4

[log] User(displayName: null, email: dantesttest74@gmail.com, emailVerified: true, isAnonymous: false, metadata: UserMetadata(creationTime: 2022-09-27 07:33:37.872Z, lastSignInTime: 2022-11-22 12:53:53.703Z), phoneNumber: null, photoURL: https://lh3.googleusercontent.com/a/default-user=s96-c, providerData, [UserInfo(displayName: Dantest test, email: dantesttest74@gmail.com, phoneNumber: null, photoURL: https://lh3.googleusercontent.com/a/ALm5wu0JirRmcc1eFZpZBwxt3VIdf3F6tJm59HQKD6iv=s96-c, providerId: google.com, uid: 110084087253026799782)], refreshToken: , tenantId: null, uid: LzrfQLxSz6X0NdEH8t9i2PxzRez1)

If this doesn't represent your case, please provide minimal code sample along with a short video that shows the behavior.

Wackymax commented 1 year ago

It happens when there are snapshot listeners active. Happens for me as well.

perepechin commented 1 year ago

I have a similar issue on the phone, and I couldn't reproduce it on the iOS Emulator.

App crashes immediately after Sign In (if I open the app after the crash user will be logged in) and Sign Out (if I open the app after the crash, the user will be logged out).

iOS version 16.0.3, and I have the same behavior on the iPhone with 15.6 version of iOS.

Stack Trace looks like this:

Crashed: com.google.firebase.firestore
0  libsystem_kernel.dylib         0x7200 __pthread_kill + 8
1  libsystem_pthread.dylib        0x71ac pthread_kill + 268
2  libsystem_c.dylib              0x20ca0 abort + 180
3  libsystem_malloc.dylib         0x1d548 _malloc_put + 550
4  libsystem_malloc.dylib         0x1d720 malloc_report + 64
5  libsystem_malloc.dylib         0x147c free + 300
6  nanopb                         0x6494 pb_release_single_field + 336
7  nanopb                         0x6218 pb_release + 44
8  nanopb                         0x6424 pb_release_single_field + 224
9  nanopb                         0x6218 pb_release + 44
10 nanopb                         0x6424 pb_release_single_field + 224
11 nanopb                         0x6218 pb_release + 44
12 Runner                         0xfba7c firebase::firestore::nanopb::Message<firebase::firestore::_google_firestore_v1_Value>::~Message() + 4344986236
13 Runner                         0xa696c std::__1::shared_ptr<firebase::firestore::nanopb::Message<firebase::firestore::_google_firestore_v1_Value>>::~shared_ptr() + 4344637804
14 Runner                         0xb9d40 firebase::firestore::core::FieldFilter::Rep::~Rep() + 4344716608
15 Runner                         0xa696c std::__1::shared_ptr<firebase::firestore::nanopb::Message<firebase::firestore::_google_firestore_v1_Value>>::~shared_ptr() + 4344637804
16 Runner                         0xa012c std::__1::__vector_base<std::__1::shared_ptr<firebase::firestore::core::QueryListener>, std::__1::allocator<std::__1::shared_ptr<firebase::firestore::core::QueryListener>>>::~__vector_base() + 4344611116
17 Runner                         0x10fb28 firebase::firestore::core::InFilter::Rep::~Rep() + 4345068328
18 Runner                         0xa696c std::__1::shared_ptr<firebase::firestore::nanopb::Message<firebase::firestore::_google_firestore_v1_Value>>::~shared_ptr() + 4344637804
19 Runner                         0xa012c std::__1::__vector_base<std::__1::shared_ptr<firebase::firestore::core::QueryListener>, std::__1::allocator<std::__1::shared_ptr<firebase::firestore::core::QueryListener>>>::~__vector_base() + 4344611116
20 Runner                         0x124b34 std::__1::__hash_table<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>, std::__1::__unordered_map_hasher<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>, std::__1::hash<firebase::firestore::core::Target>, std::__1::equal_to<firebase::firestore::core::Target>, true>, std::__1::__unordered_map_equal<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>, std::__1::equal_to<firebase::firestore::core::Target>, std::__1::hash<firebase::firestore::core::Target>, true>, std::__1::allocator<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>>>::__deallocate_node(std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>, void*>*>*) + 4345154356
21 Runner                         0x124aa4 std::__1::__hash_table<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>, std::__1::__unordered_map_hasher<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>, std::__1::hash<firebase::firestore::core::Target>, std::__1::equal_to<firebase::firestore::core::Target>, true>, std::__1::__unordered_map_equal<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>, std::__1::equal_to<firebase::firestore::core::Target>, std::__1::hash<firebase::firestore::core::Target>, true>, std::__1::allocator<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target>>>>>::~__hash_table() + 4345154212
22 Runner                         0x12119c firebase::firestore::local::LevelDbIndexManager::~LevelDbIndexManager() + 4345139612
23 Runner                         0x13ad70 void std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, void*>>>::destroy<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, void, void>(std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, void*>>&, std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>*) + 4345245040
24 Runner                         0x13b538 std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, void*>>>>::~unique_ptr() + 4345247032
25 Runner                         0x13b918 unsigned long std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager>>>>>::__erase_unique<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 4345248024
26 Runner                         0x13a624 firebase::firestore::local::LevelDbPersistence::ReleaseOtherUserSpecificComponents(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 4345243172
27 Runner                         0x14e574 firebase::firestore::local::LocalStore::HandleUserChange(firebase::firestore::credentials::User const&) + 4345324916
28 Runner                         0x1a9acc firebase::firestore::core::SyncEngine::HandleCredentialChange(firebase::firestore::credentials::User const&) + 4345699020
29 Runner                         0xdd9e8 std::__1::__function::__func<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User>>, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider>>)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'(), std::__1::allocator<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User>>, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider>>)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'()>, void ()>::operator()() + 4344863208
30 Runner                         0x8fa10 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) + 4344543760
31 Runner                         0x1b80ec firebase::firestore::util::Task::ExecuteAndRelease() + 4345757932
32 libdispatch.dylib              0x3fdc _dispatch_client_callout + 20
33 libdispatch.dylib              0xb694 _dispatch_lane_serial_drain + 672
34 libdispatch.dylib              0xc1e0 _dispatch_lane_invoke + 384
35 libdispatch.dylib              0x16e10 _dispatch_workloop_worker_thread + 652
36 libsystem_pthread.dylib        0xdf8 _pthread_wqthread + 288
37 libsystem_pthread.dylib        0xb98 start_wqthread + 8
Wackymax commented 1 year ago

Here is my stack trace

Crashed: com.google.firebase.firestore
0  libsystem_kernel.dylib         0x9120 __pthread_kill + 8
1  libsystem_pthread.dylib        0x71e8 pthread_kill + 256
2  libsystem_c.dylib              0x74e28 abort + 124
3  libsystem_malloc.dylib         0x22370 malloc_vreport + 912
4  libsystem_malloc.dylib         0x22534 malloc_report + 60
5  libsystem_malloc.dylib         0x16490 find_zone_and_free + 292
6  nanopb                         0x33c4 pb_release_single_field + 808
7  nanopb                         0x2eec pb_release + 76
8  nanopb                         0x32a0 pb_release_single_field + 516
9  nanopb                         0x2eec pb_release + 76
10 nanopb                         0x32a0 pb_release_single_field + 516
11 nanopb                         0x2eec pb_release + 76
12 Runner                         0x2924d8 firebase::firestore::nanopb::Message<firebase::firestore::_google_firestore_v1_Value>::~Message() + 40
13 Runner                         0x24d830 std::__1::shared_ptr<firebase::firestore::nanopb::Message<firebase::firestore::_google_firestore_v1_Value> >::~shared_ptr() + 56
14 Runner                         0x24ceac firebase::firestore::core::FieldFilter::Rep::~Rep() + 40
15 Runner                         0x28ef00 std::__1::shared_ptr<firebase::firestore::core::Filter::Rep const>::~shared_ptr() + 56
16 Runner                         0x232944 std::__1::__vector_base<firebase::firestore::core::FieldFilter, std::__1::allocator<firebase::firestore::core::FieldFilter> >::~__vector_base() + 44
17 Runner                         0x2a6d08 firebase::firestore::core::InFilter::Rep::~Rep() + 76
18 Runner                         0x28ef00 std::__1::shared_ptr<firebase::firestore::core::Filter::Rep const>::~shared_ptr() + 56
19 Runner                         0x28ee9c std::__1::__vector_base<firebase::firestore::core::Filter, std::__1::allocator<firebase::firestore::core::Filter> >::~__vector_base() + 44
20 Runner                         0x2bcab4 std::__1::__hash_table<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > >, std::__1::__unordered_map_hasher<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > >, std::__1::hash<firebase::firestore::core::Target>, std::__1::equal_to<firebase::firestore::core::Target>, true>, std::__1::__unordered_map_equal<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > >, std::__1::equal_to<firebase::firestore::core::Target>, std::__1::hash<firebase::firestore::core::Target>, true>, std::__1::allocator<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > > > >::__deallocate_node(std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > >, void*>*>*) + 112
21 Runner                         0x2bca24 std::__1::__hash_table<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > >, std::__1::__unordered_map_hasher<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > >, std::__1::hash<firebase::firestore::core::Target>, std::__1::equal_to<firebase::firestore::core::Target>, true>, std::__1::__unordered_map_equal<firebase::firestore::core::Target, std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > >, std::__1::equal_to<firebase::firestore::core::Target>, std::__1::hash<firebase::firestore::core::Target>, true>, std::__1::allocator<std::__1::__hash_value_type<firebase::firestore::core::Target, std::__1::vector<firebase::firestore::core::Target, std::__1::allocator<firebase::firestore::core::Target> > > > >::~__hash_table() + 24
22 Runner                         0x2b9090 firebase::firestore::local::LevelDbIndexManager::~LevelDbIndexManager() + 128
23 Runner                         0x2d3a08 void std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, void*> > >::destroy<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, void, void>(std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, void*> >&, std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >*) + 40
24 Runner                         0x2d443c std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, void*>, std::__1::__hash_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, void*> > > >::~unique_ptr() + 44
25 Runner                         0x2d56b8 unsigned long std::__1::__hash_table<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, std::__1::__unordered_map_hasher<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::unique_ptr<firebase::firestore::local::LevelDbIndexManager, std::__1::default_delete<firebase::firestore::local::LevelDbIndexManager> > > > >::__erase_unique<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 52
26 Runner                         0x2d32bc firebase::firestore::local::LevelDbPersistence::ReleaseOtherUserSpecificComponents(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 256
27 Runner                         0x2e8cf0 firebase::firestore::local::LocalStore::HandleUserChange(firebase::firestore::credentials::User const&) + 312
28 Runner                         0x34e75c firebase::firestore::core::SyncEngine::HandleCredentialChange(firebase::firestore::credentials::User const&) + 344
29 Runner                         0x274684 std::__1::__function::__func<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User> >, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider> >)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'(), std::__1::allocator<firebase::firestore::core::FirestoreClient::Create(firebase::firestore::core::DatabaseInfo const&, firebase::firestore::api::Settings const&, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<firebase::firestore::credentials::AuthToken, firebase::firestore::credentials::User> >, std::__1::shared_ptr<firebase::firestore::credentials::CredentialsProvider<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::shared_ptr<firebase::firestore::util::Executor>, std::__1::shared_ptr<firebase::firestore::util::AsyncQueue>, std::__1::unique_ptr<firebase::firestore::remote::FirebaseMetadataProvider, std::__1::default_delete<firebase::firestore::remote::FirebaseMetadataProvider> >)::$_3::operator()(firebase::firestore::credentials::User)::'lambda0'()>, void ()>::operator()() + 164
30 Runner                         0x21f164 firebase::firestore::util::AsyncQueue::ExecuteBlocking(std::__1::function<void ()> const&) + 68
31 Runner                         0x360790 firebase::firestore::util::Task::ExecuteAndRelease() + 184
32 libdispatch.dylib              0x3768 _dispatch_client_callout + 16
33 libdispatch.dylib              0xb7f8 _dispatch_lane_serial_drain + 780
34 libdispatch.dylib              0xc43c _dispatch_lane_invoke + 392
35 libdispatch.dylib              0x18624 _dispatch_workloop_worker_thread + 772
36 libsystem_pthread.dylib        0x38fc _pthread_wqthread + 284
37 libsystem_pthread.dylib        0x26c0 start_wqthread + 8
Wackymax commented 1 year ago

Social logins are crashing with the same error

zachary-russell commented 1 year ago

I am replicating the same error with google sign in on iOS. Sign in with apple still works fine.

mhamTech commented 1 year ago

@mhamTech I used the plugin example with latest versions as you mentioned above and ran it on iOS device, used google sign in and then signed out which worked properly as below without throwing any crash or error.

RPReplay-Final1669121666.MP4 [log] User(displayName: null, email: dantesttest74@gmail.com, emailVerified: true, isAnonymous: false, metadata: UserMetadata(creationTime: 2022-09-27 07:33:37.872Z, lastSignInTime: 2022-11-22 12:53:53.703Z), phoneNumber: null, photoURL: https://lh3.googleusercontent.com/a/default-user=s96-c, providerData, [UserInfo(displayName: Dantest test, email: dantesttest74@gmail.com, phoneNumber: null, photoURL: https://lh3.googleusercontent.com/a/ALm5wu0JirRmcc1eFZpZBwxt3VIdf3F6tJm59HQKD6iv=s96-c, providerId: google.com, uid: 110084087253026799782)], refreshToken: , tenantId: null, uid: LzrfQLxSz6X0NdEH8t9i2PxzRez1)

If this doesn't represent your case, please provide minimal code sample along with a short video that shows the behavior.

Try with firestore snapshot listeners. I have like 6 snapshot listeners in my project. I cancelled all listeners before signing out but still i have crash on IOS devices.

There is no log or trace provided because the application crash immediately.

mhamTech commented 1 year ago

It happens when there are snapshot listeners active. Happens for me as well.

Yeah I have like 6 snapshot listeners. I cancelled all listeners before signing out but still i have crash on IOS devices.

Any solution ?

mhamTech commented 1 year ago

@mhamTech I used the plugin example with latest versions as you mentioned above and ran it on iOS device, used google sign in and then signed out which worked properly as below without throwing any crash or error.

RPReplay-Final1669121666.MP4 [log] User(displayName: null, email: dantesttest74@gmail.com, emailVerified: true, isAnonymous: false, metadata: UserMetadata(creationTime: 2022-09-27 07:33:37.872Z, lastSignInTime: 2022-11-22 12:53:53.703Z), phoneNumber: null, photoURL: https://lh3.googleusercontent.com/a/default-user=s96-c, providerData, [UserInfo(displayName: Dantest test, email: dantesttest74@gmail.com, phoneNumber: null, photoURL: https://lh3.googleusercontent.com/a/ALm5wu0JirRmcc1eFZpZBwxt3VIdf3F6tJm59HQKD6iv=s96-c, providerId: google.com, uid: 110084087253026799782)], refreshToken: , tenantId: null, uid: LzrfQLxSz6X0NdEH8t9i2PxzRez1)

If this doesn't represent your case, please provide minimal code sample along with a short video that shows the behavior.

Here is log: details.txt

darshankawar commented 1 year ago

@mhamTech and everybody facing this issue, please provide a minimal code sample involving snapshot listeners, so that we can verify and make it actionable accordingly.

mhamTech commented 1 year ago

@mhamTech and everybody facing this issue, please provide a minimal code sample involving snapshot listeners, so that we can verify and make it actionable accordingly.

Some snapshot listeners:

  static void startCurrentUserListener({
    final Function(UserModel updatedUser)? onChanged,
    final VoidCallback? onNotExist,
  }) {
    _currentUserListener = _firestore.collection("Users").doc(Authentication.fullUserId).snapshots().listen((event) {
      if (event.exists) {
        currentUser.value = UserModel.fromMap(map: event.data()!);
        onChanged?.call(currentUser.value!);
      } else {
        onNotExist?.call();
      }
    });
  }
static void startCurrentAppConfigurationListener({
    final Function(AppConfigurationModel updatedAppConfiguration)? onChanged,
    final VoidCallback? onNotExist,
  }) {
    _currentAppConfigurationListener = _firestore
        .collection("Configurations")
        .doc(LocationManager.startUpLocationInformation!.countryId)
        .snapshots()
        .listen((event) {
      if (event.exists) {
        currentAppConfiguration.value = AppConfigurationModel.fromMap(map: event.data()!);
        onChanged?.call(currentAppConfiguration.value!);
      } else {
        onNotExist?.call();
      }
    });
  }

And here i'm cancelling the listeners before signing out or onDispose():

static Future<void> cancelListeners() async {
    await _currentAppConfigurationListener?.cancel();
    await _currentUserListener?.cancel();
  }

Sign out method:

  static Future<bool> signOut({
    final VoidCallback? onStart,
    final VoidCallback? onSuccess,
    final Function(String errorTextKey)? onError,
    final VoidCallback? onComplete,
  }) async {
    try {
      onStart?.call();
      await _firebaseAuth.signOut().timeout(const Duration(seconds: 8));
      onSuccess?.call();
      return true;
    } on TimeoutException {
      onError?.call("connection_timeout");
    } catch (_) {
      onError?.call("error_try_again");
    } finally {
      onComplete?.call();
    }
    return false;
  }

Result: Application crashes immediately on IOS devices even on release mode.

darshankawar commented 1 year ago

@mhamTech Please provide a complete minimal code sample (ex: main.dart) that we can directly use.

mhamTech commented 1 year ago

@mhamTech Please provide a complete minimal code sample (ex: main.dart) that we can directly use.

The application is very complex, a lot of things connected together. If i would share what you requested, i have to share multiple files which is not possible.

You can try the following(IOS devices): 1-Add firebase to a project. 2-Sign in[FirebaseAuth]. 3-Add two or more listeners(snapshots.listen)[Firestore] to any collection in firebase. 4-Sign out[FirebaseAuth].

Result: Application crashes immediately even if you cancelled the listeners before signing out.

dnkoulouris commented 1 year ago

Same issue here too. I can confirm. In my app, I commented out all my .snapshots() listeners, and logout works fine.

dnkoulouris commented 1 year ago

After further investigating all my code's .snapshots(), the issue occurs if the query contains a whereIn condition

mariopepe commented 1 year ago

If useful my app the login is via phone number only

Happening for me as well I do have 2 listeners active that I do not close, but I did not expect this to happen, in previous version surely it was not necessary!

migdev-br commented 1 year ago

I also did some tests on my end and it seems the "whereIn" query is crashing the app when signing out, only on ios.

mhamTech commented 1 year ago

After further investigating all my code's .snapshots(), the issue occurs if the query contains a whereIn condition

Yeah, you are right, I commented out all whereIn and sign out works perfectly.

darshankawar commented 1 year ago

Thanks for the updates. Based on the reports and the crash log, keeping this issue open and for team's attention.

/cc @Lyokone

Lyokone commented 1 year ago

Thanks for the report, I'm investigating this πŸ‘

Lyokone commented 1 year ago

I've tried to reproduce this on the example app and I've got no crash: https://github.com/firebase/flutterfire/pull/10010

Please provide a reproducible example.

mariopepe commented 1 year ago

I would need to make a sample app from scratch, hopefully I have time tonight.

@Lyokone in your tests, did you try to make a listener with a query whereIn (as per this comment)?

Thanks

Lyokone commented 1 year ago

You can check the linked PR if you want to start quickly or check what I did to reproduce. I indeed used whereIn.

mhamTech commented 1 year ago

You can check the linked PR if you want to start quickly or check what I did to reproduce. I indeed used whereIn.

Hello, and thanks for replying.

To avoid an application crash on sign-out with firebase_auth, I had to remove whereIn condition from a snapshot listener on cloud_firestore.

This resulted in some limitations on the application's features, but for now, it's fine.

Please try the following(IOS devices): 1-Add firebase to a project. 2-Sign in - firebase_auth (We are using phone number to sign in). 3-Add two or more listeners(snapshots.listen) - cloud_firestore to any collection on firebase, don't forget to insert whereIn condition. 4-Run the application. 5-Sign out - firebase_auth.

Lyokone commented 1 year ago

@mhamTech As you can see in #10010, I've tried to reproduce the crash with whereIn and the app is still not crashing. Since there is a native issue opened as well, I suspect this to not be caused by FlutterFire but by the iOS SDK.

Anyway, I still need a Flutter repro. You can use #10010 as a base to try to reproduce the error.

wu-hui commented 1 year ago

hey there, this is an issue where whereIn cannot handle nested array. So not only there needs to be a whereIn query, but the array needs to have an array in it as well. This is known to the native SDK team, and we are addressing it at the moment.

Source: I am an engineer working on the iOS native firestore SDK.

mariopepe commented 1 year ago

[FIX BELOW]

For anyone interested, this is the issue on the iOS SDK to track. It affects iOS SDK >= 10.2.0

So for us, Flutter people, we need to downgrade to firebase_auth: 4.1.2 (⚠️ REMEMBER: NO CARET OPERATOR ⚠️)

It may be necessary to downgrade firebase_core too, the good version is: firebase_core: 2.2.0

mhamTech commented 1 year ago

[FIX BELOW]

For anyone interested, this is the issue on the iOS SDK to track. It affects iOS SDK >= 10.2.0

So for us, Flutter people, we need to downgrade to firebase_auth: 4.1.2 (⚠️ REMEMBER: NO CARROT OPERATOR ⚠️)

It may be necessary to downgrade firebase_core too, the good version is: firebase_core: 2.2.0

I tried this solution before, not working for me :( The only solution works for now is to remove whereIn from any cloud_firestore query.

BTW, what do you mean here "(⚠️ REMEMBER: NO CARROT OPERATOR ⚠️)" ?

mariopepe commented 1 year ago

@mhamTech you can read more here.

In short, if you have as dependencies firebase_auth: ^4.1.2 with the caret operator (i.e. ^), you are actually getting the latest version (which contains non-breaking changes), so in this case you are getting the broken version 4.1.4.

In other words, to downgarde any package in flutter be always sure to remove the caret operator.

So, to effectively downgrade a package, just to be sure, you have to remove the caret operator ^.

On another note, I honestly think that the @flutterfire team should mark as breaking change any update of any flutter package that has the native SDK changing. Native SDKs are not responsibility of flutterfire team so I think it would be better to set them as breaking change.

mhamTech commented 1 year ago

@mhamTech you can read more here.

In short, if you have as dependencies firebase_auth: ^4.1.2 with the caret operator (i.e. ^), you are actually getting the latest version (which contains non-breaking changes), so in this case you are getting the broken version 4.1.4.

In other words, to downgarde any package in flutter be always sure to remove the caret operator.

So, to effectively downgrade a package, just to be sure, you have to remove the caret operator ^.

On another note, I honestly think that the @flutterfire team should mark as breaking change any update of any flutter package that has the native SDK changing. Native SDKs are not responsibility of flutterfire team so I think it would be better to set them as breaking change.

Thank you for clarifying.

percula commented 1 year ago

[FIX BELOW]
For anyone interested, this is the issue on the iOS SDK to track. It affects iOS SDK >= 10.2.0
So for us, Flutter people, we need to downgrade to firebase_auth: 4.1.2 (⚠️ REMEMBER: NO CARROT OPERATOR ⚠️)
It may be necessary to downgrade firebase_core too, the good version is: firebase_core: 2.2.0

I tried this solution before, not working for me :( The only solution works for now is to remove whereIn from any cloud_firestore query.

BTW, what do you mean here "(⚠️ REMEMBER: NO CARROT OPERATOR ⚠️)" ?

This worked, thanks! For anyone wondering, it definitely is necessary to downgrade firebase_core too.

AresVampire commented 1 year ago

seems it is fixed with 10.3.0

Lyokone commented 1 year ago

10.3.0 Will be released this afternoon

Lyokone commented 1 year ago

It was released with firebase_auth 4.2.0 and firebase_core 2.4.0