Closed Fernandomr88 closed 12 months ago
@Fernandomr88 This is not a bug but you have to manually close the stream. you can check the remote config example from the plugin's repo
StreamSubscription? subscription;
if (subscription != null) {
await subscription!.cancel();
subscription = null;
}
subscription = _remoteConfig.onConfigUpdated.listen((event) async {
await _remoteConfig.activate();
// Fetch new data
});
UPDATE: Even after putting the manual close stream, stream is not closing properly when performing a hot restart.
@Fernandomr88
Are you getting unable to connect to server
log as well ?
See if this issue resembles yours or not.
@Fernandomr88 This is not a bug but you have to manually close the stream. you can check the remote config example from the plugin's repo
StreamSubscription? subscription; if (subscription != null) { await subscription!.cancel(); subscription = null; } subscription = _remoteConfig.onConfigUpdated.listen((event) async { await _remoteConfig.activate(); // Fetch new data });
UPDATE: Even after putting the manual close stream, stream is not closing properly when performing a hot restart.
I was already closing it properly, this is happening all the same.
@Fernandomr88 Are you getting
unable to connect to server
log as well ? See if this issue resembles yours or not.
nope
@Fernandomr88 This is not a bug but you have to manually close the stream. you can check the remote config example from the plugin's repo
StreamSubscription? subscription; if (subscription != null) { await subscription!.cancel(); subscription = null; } subscription = _remoteConfig.onConfigUpdated.listen((event) async { await _remoteConfig.activate(); // Fetch new data });
UPDATE: Even after putting the manual close stream, the stream is not closing properly when performing a hot restart.
I was already closing it properly, this is happening all the same.
Facing the same issue, I thought closing the stream manually will resolve this issue.
@Fernandomr88 Can you provide us complete minimal reproducible code sample that shows the reported error ?
@Fernandomr88 Can you provide us complete minimal reproducible code sample that shows the reported error ?
Sure, just tried with this code and it was reproducible (with all firebase stuff configured properly):
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
StreamSubscription? remoteConfigSubscription;
@override
void initState() {
initRemoteConfig();
super.initState();
}
void _incrementCounter() {
setState(() {
_counter++;
});
}
Future<void> initRemoteConfig() async {
final remoteConfig = FirebaseRemoteConfig.instance;
try {
await remoteConfig.setConfigSettings(
RemoteConfigSettings(
fetchTimeout: const Duration(minutes: 1),
minimumFetchInterval: const Duration(hours: 2),
),
);
await remoteConfig.fetchAndActivate();
if (remoteConfigSubscription != null) {
await remoteConfigSubscription!.cancel();
remoteConfigSubscription = null;
}
remoteConfigSubscription = remoteConfig.onConfigUpdated.listen((event) async {
await remoteConfig.activate();
print('RemoteConfig UPDATED: ${event.updatedKeys}');
}, onError: (e) {
print('RemoteConfig ERROR: $e');
});
} catch (e) {
print(e);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}
Thanks for the update. Using above code sample and running on Android emulator, hot reloading throws the same error as reported.
any updates?
any updates ?
I'm not sure if this is the same for everyone else, but I also experience constant ANRs during development when I run into this issue. It's made debugging on Android impossible for me without turning off Firebase services. Thankfully I have a killswitch in an env file to do so.
Bug report
Describe the bug I have been using remote config in my flutter app for over a year now. Just started to use the realtime update and every time I hot reload the app ON ANDROID it prints this error: This does not happen on iOS.
running the app for the first time doesn't cause the same behavior.
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.4, on macOS 13.4 22F66 darwin-arm64, locale pt-BR) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc2) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] VS Code (version 1.79.0) [✓] Connected device (3 available) [✓] Network resources • No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Dart SDK 3.0.3 Flutter SDK 3.10.4 xyzapp 1.2.3+77 dependencies: - amplify_auth_cognito 1.1.1 [amplify_analytics_pinpoint amplify_analytics_pinpoint_dart amplify_auth_cognito_dart amplify_core amplify_flutter amplify_secure_storage async flutter meta path plugin_platform_interface] - amplify_flutter 1.1.1 [amplify_core amplify_secure_storage aws_common collection flutter meta] - async 2.11.0 [collection meta] - badges 3.1.1 [flutter] - brasil_fields 1.13.1 [flutter intl] - camera 0.10.5+2 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle quiver] - cloud_functions 4.3.3 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter] - cupertino_icons 1.0.5 - currency_text_input_formatter 2.1.10 [flutter intl] - datetime_picker_formfield_new 2.1.0 [flutter intl] - device_info_plus 9.0.2 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32 win32_registry] - dropdown_plus 0.0.9 [flutter] - file_picker 5.3.2 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32] - firebase_analytics 10.4.3 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_app_installations 0.2.3+3 [firebase_app_installations_platform_interface firebase_app_installations_web firebase_core firebase_core_platform_interface flutter] - firebase_core 2.14.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.3 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 14.6.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_performance 0.9.2+3 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter] - firebase_remote_config 4.2.3 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - fl_chart 0.62.0 [equatable flutter] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_animate 4.1.1+1 [flutter] - flutter_app_badger 1.5.0 [flutter] - flutter_credit_card 3.0.6 [flutter] - flutter_local_notifications 9.9.1 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_pdfview 1.3.1 [flutter] - flutter_staggered_grid_view 0.6.2 [flutter] - flutter_statusbarcolor_ns 0.5.0 [flutter] - fluttertoast 8.2.2 [flutter flutter_web_plugins] - grouped_list 5.1.2 [flutter] - http 0.13.6 [async http_parser meta] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - intl 0.18.1 [clock meta path] - launch_review 3.0.1 [flutter] - local_auth 2.1.6 [flutter local_auth_android local_auth_ios local_auth_platform_interface local_auth_windows] - open_app_file 4.0.1 [flutter ffi] - package_info_plus 4.0.2 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path 1.8.3 - path_provider 2.0.15 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - permission_handler 10.3.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - qr_code_scanner 1.0.1 [js flutter flutter_web_plugins] - share_plus 7.0.2 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi win32] - shared_preferences 2.1.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - url_launcher 6.1.11 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - flutter_launcher_icons 0.13.1 [args checked_yaml cli_util image json_annotation path yaml] - flutter_lints 2.0.1 [lints] dependency overrides: - intl 0.18.1 [clock meta path] transitive dependencies: - _flutterfire_internals 1.3.3 [collection firebase_core firebase_core_platform_interface flutter meta] - amplify_analytics_pinpoint 1.1.1 [amplify_analytics_pinpoint_dart amplify_core amplify_db_common amplify_secure_storage aws_common device_info_plus flutter meta package_info_plus path_provider] - amplify_analytics_pinpoint_dart 0.3.0 [amplify_core amplify_db_common_dart amplify_secure_storage_dart aws_common aws_signature_v4 built_collection built_value collection drift intl meta path smithy smithy_aws uuid] - amplify_auth_cognito_dart 0.10.0+1 [amplify_analytics_pinpoint_dart amplify_core amplify_secure_storage_dart async aws_common aws_signature_v4 built_collection built_value collection convert crypto fixnum http intl js json_annotation meta oauth2 path smithy smithy_aws stream_transform uuid worker_bee] - amplify_core 1.1.1 [async aws_common aws_signature_v4 collection intl json_annotation logging meta retry stack_trace uuid] - amplify_db_common 0.3.0 [amplify_db_common_dart drift flutter path path_provider] - amplify_db_common_dart 0.3.0 [amplify_core async aws_common drift meta path sqlite3] - amplify_secure_storage 0.4.0 [amplify_secure_storage_dart async file flutter meta path path_provider path_provider_windows] - amplify_secure_storage_dart 0.4.0+1 [async aws_common built_collection built_value ffi file js meta path win32 worker_bee] - archive 3.3.7 [crypto path pointycastle] - args 2.4.2 - aws_common 0.5.0+1 [async built_collection built_value collection http2 js json_annotation logging meta mime os_detect path stream_transform uuid] - aws_signature_v4 0.4.0+1 [async aws_common collection convert crypto json_annotation meta path] - boolean_selector 2.1.1 [source_span string_scanner] - built_collection 5.1.1 - built_value 8.5.0 [built_collection collection fixnum meta] - camera_android 0.10.8+2 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform] - camera_avfoundation 0.9.13+2 [camera_platform_interface flutter stream_transform] - camera_platform_interface 2.5.1 [cross_file flutter plugin_platform_interface stream_transform] - camera_web 0.3.1+4 [camera_platform_interface flutter flutter_web_plugins stream_transform] - characters 1.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - cli_util 0.4.0 [meta path] - clock 1.1.1 - cloud_functions_platform_interface 5.4.3 [firebase_core flutter meta plugin_platform_interface] - cloud_functions_web 4.5.3 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.17.1 - convert 3.1.1 [typed_data] - crclib 3.0.0 [meta tuple] - cross_file 0.3.3+4 [js meta] - crypto 3.0.3 [typed_data] - dbus 0.7.8 [args ffi meta xml] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - drift 2.8.2 [async convert collection js meta stream_channel sqlite3] - equatable 2.0.5 [collection meta] - fake_async 1.3.1 [clock collection] - ffi 2.0.2 - file 6.1.4 [meta path] - firebase_analytics_platform_interface 3.6.3 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.4+3 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_app_installations_platform_interface 0.1.4+3 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_installations_web 0.1.3+3 [_flutterfire_internals firebase_app_installations_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.6.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.3 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.3 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.3 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_performance_platform_interface 0.1.4+3 [_flutterfire_internals firebase_core flutter plugin_platform_interface] - firebase_performance_web 0.1.4+3 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins js] - firebase_remote_config_platform_interface 1.4.3 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.4.3 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - fixnum 1.1.0 - flutter_local_notifications_linux 0.5.1 [flutter flutter_local_notifications_platform_interface dbus path xdg_directories] - flutter_local_notifications_platform_interface 5.0.0 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 2.0.15 [flutter] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - http2 2.1.0 - image 4.0.17 [archive meta xml] - js 0.6.7 [meta] - json_annotation 4.8.1 [meta] - lints 2.1.1 - local_auth_android 1.0.32 [flutter flutter_plugin_android_lifecycle intl local_auth_platform_interface] - local_auth_ios 1.1.3 [flutter intl local_auth_platform_interface] - local_auth_platform_interface 1.0.7 [flutter plugin_platform_interface] - local_auth_windows 1.0.8 [flutter local_auth_platform_interface] - logging 1.2.0 - matcher 0.12.15 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.2.0 - meta 1.9.1 - mime 1.0.4 - oauth2 2.0.2 [collection crypto http http_parser] - os_detect 2.0.1 - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path_provider_android 2.0.27 [flutter path_provider_platform_interface] - path_provider_foundation 2.2.3 [flutter path_provider_platform_interface] - path_provider_linux 2.1.11 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.7 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 10.2.3 [flutter permission_handler_platform_interface] - permission_handler_apple 9.1.0 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.10.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.2 [flutter permission_handler_platform_interface] - petitparser 5.4.0 [meta] - platform 3.1.0 - plugin_platform_interface 2.1.4 [meta] - pointycastle 3.7.3 [collection convert js] - process 4.2.4 [file path platform] - quiver 3.2.1 [matcher] - retry 3.1.2 - share_plus_platform_interface 3.2.1 [cross_file flutter meta mime plugin_platform_interface path_provider uuid] - shared_preferences_android 2.1.4 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.2.2 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.2.0 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.2.0 [flutter plugin_platform_interface] - shared_preferences_web 2.1.0 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.2.0 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.1 [async collection http_parser path stack_trace stream_channel] - sky_engine 0.0.99 - smithy 0.5.0+1 [async aws_common built_collection built_value collection convert crypto fixnum http_parser intl json_annotation meta path retry shelf typed_data xml] - smithy_aws 0.5.0+1 [aws_common aws_signature_v4 built_collection built_value collection convert crclib crypto intl json_annotation meta path smithy xml] - source_span 1.9.1 [collection path term_glyph] - sqlite3 1.11.2 [collection ffi js meta path] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - term_glyph 1.2.1 - test_api 0.5.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.8.0 [path] - tuple 2.0.2 - typed_data 1.3.2 [collection] - url_launcher_android 6.0.35 [flutter url_launcher_platform_interface] - url_launcher_ios 6.1.4 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.5 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.17 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.6 [flutter url_launcher_platform_interface] - uuid 3.0.7 [crypto] - vector_math 2.1.4 - win32 5.0.3 [ffi] - win32_registry 1.1.1 [ffi win32] - worker_bee 0.2.0 [async aws_common built_collection built_value collection js meta path stack_trace stream_channel stream_transform] - xdg_directories 0.2.0+3 [meta path process] - xml 6.3.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```