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.65k stars 3.96k forks source link

[firebase_storage]: Error thrown when calling FirebaseStorage multiple times in [Add-to-App] #12988

Closed BunnarithHeang closed 2 months ago

BunnarithHeang commented 3 months ago

Is there an existing issue for this?

Which plugins are affected?

Storage

Which platforms are affected?

iOS

Description

I have an issue with calling FirebaseStorage functions in embedded(Add-to-App) Flutter applications when launching the applications for the second or third time. I tried calling any function in Dart code but it does not return any value.

Reproducing the issue

Upon checking the iOS code inside firebase_storage package from the message thrown in the console log, I found that in FLTFirebaseStoragePlugin.m function registerWithRegistrar (line 108), I found a condition to check if MethodChannel has already been assigned before, and it will return from that function. Meaning any subsequent function calls to this package does not trigger to native side.

Screenshot 2024-06-22 at 11 06 06 at night

And I have verified with the same register function in other firebase packages, all do not contain that condition to prevent multiple registrations.

Firebase Core version

10.15.0

Flutter Version

3.7.7

Relevant Log Output

FLTFirebaseStorage was already registered. If using isolates, you can safely ignore this message.

Flutter dependencies

Expand Flutter dependencies snippet
```yaml Dart SDK 2.19.4 Flutter SDK 3.7.7 dependencies: - cloud_firestore 4.9.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - firebase_auth 4.10.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.17.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.7 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_database 10.2.7 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter] - firebase_remote_config 4.2.7 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - firebase_storage 11.2.8 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] transitive dependencies: - _flutterfire_internals 1.3.7 [collection firebase_core firebase_core_platform_interface flutter meta] - cloud_firestore_platform_interface 5.16.2 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.7.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.19.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.8.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.8.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_database_platform_interface 0.2.5+7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_database_web 0.2.3+7 [firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins js] - firebase_remote_config_platform_interface 1.4.7 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.4.7 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - firebase_storage_platform_interface 4.4.7 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.8 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] ```

Additional context and comments

FYI: the Flutter dependencies that I include are only the dependencies that are related firebase packages

TarekkMA commented 3 months ago

@BunnarithHeang Thank you for reporting this bug. Can you please provide a small reproduction example of this issue? Additionally, could you explain why you need to initialize Firebase Storage multiple times?

BunnarithHeang commented 3 months ago

@TarekkMA Technically, I am not actually initializing Firebase Storage multiple times but when I try to present the FlutterViewController multiple times and call any firebase_storage function, it will trigger the registerWithRegistrar function in firebase_storage again and again. However, I observe that the core Firebase Storage instance in native iOS is still alive, the thing that gets initialized multiple times is actually the firebase_storage Flutter package.

FYI: The app host is using native iOS, and I am adding Flutter apps inside and present those Flutter apps.

TarekkMA commented 3 months ago

Thank you for the clarification. It would be helpful if you could provide a complete but minimal reproduction example of this issue. Thanks!

google-oss-bot commented 2 months ago

Hey @BunnarithHeang. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 months ago

Since there haven't been any recent updates here, I am going to close this issue.

@BunnarithHeang if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.