Skip to content

[firebase_app_check] Every call to getToken() on iOS (any provider) takes 200-300ms and issues a new, non-cached token #17624

@andersonjohnf

Description

@andersonjohnf

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

App Check

Which platforms are affected?

iOS

Description

Every call to getToken() on iOS (any provider) takes 200-300ms and issues a new, non-cached token. Web and Android functionality works as expected and issues a cached token in a few ms, but iOS will always issue a new token when you call FirebaseAppCheck.instance.getToken().

Interestingly, this does NOT seem to affect other Firebase features that are using AppCheck. For instance, Firestore (with AppCheck enforced) appears to be using a cached key because get commands complete in under 100ms. We've also added logging on our Golang API that proves our production iOS requests are including a newly issued AppCheck token on every request whereas our production Android build is re-using cached tokens as expected.

Reproducing the issue

final start = DateTime.now();
final appCheckToken = await FirebaseAppCheck.instance.getToken();
final end = DateTime.now();
print('Got app check token after ${end.difference(start).inMilliseconds}ms');

on Android will print 1-5ms delay, on iOS will be 200-300ms

Firebase Core version

4.0.0

Flutter Version

3.32.7

Relevant Log Output

iOS logs (tied to a button in Flutter app, hit 3s apart):
flutter: Got app check token after 268ms
flutter: Got app check token after 267ms
flutter: Got app check token after 373ms

Android logs:
I/flutter (32526): Got app check token after 19ms
I/flutter (32526): Got app check token after 13ms
I/flutter (32526): Got app check token after 8ms

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.8.1
Flutter SDK 3.32.7

dependencies:
- app_badge_plus 1.2.3 [flutter plugin_platform_interface]
- chewie 1.12.1 [cupertino_icons flutter provider video_player wakelock_plus]
- cloud_firestore 6.0.0 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- collection 1.19.1
- eas_flutter 0.0.0 [email_validator equatable flutter flutter_hooks flutter_svg http intl json_annotation]
- email_validator 3.0.0
- equatable 2.0.7 [collection meta]
- fc_native_video_thumbnail 0.17.2 [flutter plugin_platform_interface]
- file_picker 10.3.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32 cross_file web dbus]
- firebase_ai 3.1.0 [firebase_app_check firebase_auth firebase_core firebase_core_platform_interface flutter http meta web_socket_channel]
- firebase_app_check 0.4.0 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 6.0.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 4.0.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 16.0.0 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_storage 13.0.0 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_hooks 0.21.3 [flutter]
- flutter_lorem 2.0.0 [flutter]
- flutter_riverpod 2.6.1 [collection flutter meta riverpod state_notifier]
- flutter_svg 2.2.0 [flutter http vector_graphics vector_graphics_codec vector_graphics_compiler]
- freezed_annotation 3.1.0 [collection json_annotation meta]
- geolocator 14.0.2 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web geolocator_windows geolocator_linux]
- google_sign_in 7.1.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]
- hooks_riverpod 2.6.1 [collection flutter flutter_hooks flutter_riverpod riverpod state_notifier]
- http 1.5.0 [async http_parser meta web]
- image 4.5.4 [archive meta xml]
- image_picker 1.1.2 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows]
- intl 0.20.2 [clock meta path]
- json_annotation 4.9.0 [meta]
- linked_scroll_controller 0.2.0 [flutter]
- mask_text_input_formatter 2.9.0 [flutter]
- mime 2.0.0
- open_filex 4.7.0 [flutter ffi]
- package_info_plus 8.3.1 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- path_provider 2.1.5 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- pdfrx 1.3.5 [collection crypto ffi flutter http path path_provider rxdart synchronized url_launcher vector_math web dart_pubspec_licenses]
- permission_handler 12.0.1 [flutter meta permission_handler_android permission_handler_apple permission_handler_html permission_handler_windows permission_handler_platform_interface]
- photo_view 0.15.0 [flutter]
- riverpod 2.6.1 [collection meta stack_trace state_notifier]
- riverpod_annotation 2.6.1 [meta riverpod]
- rxdart 0.28.0
- scrollable_positioned_list 0.3.8 [flutter collection]
- share_plus 11.1.0 [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 web win32]
- shared_preferences 2.5.3 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- text_search 1.0.2 [tuple]
- url_launcher 6.3.2 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- uuid 4.5.1 [crypto sprintf meta fixnum]
- video_player 2.10.0 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]
- visibility_detector 0.4.0+2 [flutter]

dev dependencies:
- build_runner 2.5.4 [analyzer args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web web_socket_channel yaml]
- custom_lint 0.7.6 [analyzer analyzer_plugin args async ci cli_util collection custom_lint_core freezed_annotation json_annotation meta package_config path pub_semver pubspec_parse rxdart uuid yaml]
- flutter_launcher_icons 0.14.4 [args checked_yaml cli_util image json_annotation path yaml]
- flutter_lints 6.0.0 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]
- freezed 3.1.0 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation dart_style pub_semver]
- json_serializable 6.9.5 [analyzer async build build_config collection dart_style json_annotation meta path pub_semver pubspec_parse source_gen source_helper]
- riverpod_generator 2.6.5 [analyzer build build_config collection crypto meta path riverpod_analyzer_utils riverpod_annotation source_gen]
- riverpod_lint 2.6.5 [analyzer analyzer_plugin collection custom_lint_builder meta path riverpod riverpod_analyzer_utils source_span yaml]

transitive dependencies:
- _fe_analyzer_shared 85.0.0 [meta]
- _flutterfire_internals 1.3.60 [collection firebase_core firebase_core_platform_interface flutter meta]
- analyzer 7.6.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- analyzer_plugin 0.13.4 [analyzer collection dart_style pub_semver yaml path]
- archive 4.0.7 [crypto path posix]
- args 2.7.0
- async 2.13.0 [collection meta]
- boolean_selector 2.1.2 [source_span string_scanner]
- build 2.5.4 [analyzer async build_runner_core built_collection built_value convert crypto glob graphs logging meta package_config path pool]
- build_config 1.1.2 [checked_yaml json_annotation path pubspec_parse yaml]
- build_daemon 4.0.4 [built_collection built_value crypto http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 2.5.4 [analyzer async build build_runner_core collection convert crypto graphs logging package_config path pool pub_semver stream_transform]
- build_runner_core 9.1.2 [analyzer async build build_config build_resolvers build_runner built_collection built_value collection convert crypto glob graphs json_annotation logging meta package_config path pool timing watcher yaml]
- built_collection 5.1.1
- built_value 8.11.1 [built_collection collection fixnum meta]
- characters 1.4.0
- checked_yaml 2.0.4 [json_annotation source_span yaml]
- ci 0.1.0
- cli_util 0.4.2 [meta path]
- clock 1.1.2
- cloud_firestore_platform_interface 7.0.0 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 5.0.0 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins]
- code_builder 4.10.1 [built_collection built_value collection matcher meta]
- convert 3.1.2 [typed_data]
- cross_file 0.3.4+2 [meta web]
- crypto 3.0.6 [typed_data]
- csslib 1.0.2 [source_span]
- cupertino_icons 1.0.8
- custom_lint_builder 0.7.6 [analyzer analyzer_plugin collection custom_lint custom_lint_core custom_lint_visitor glob hotreloader meta package_config path pubspec_parse rxdart]
- custom_lint_core 0.7.5 [analyzer analyzer_plugin collection custom_lint_visitor glob matcher meta package_config path pubspec_parse source_span uuid yaml]
- custom_lint_visitor 1.0.0+7.7.0 [analyzer]
- dart_pubspec_licenses 3.0.4 [yaml path json_annotation]
- dart_style 3.1.1 [analyzer args collection package_config path pub_semver source_span yaml]
- dbus 0.7.11 [args ffi meta xml]
- fake_async 1.3.3 [clock collection]
- ffi 2.1.4
- file 7.0.1 [meta path]
- file_selector_linux 0.9.3+2 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.4+3 [cross_file file_selector_platform_interface flutter]
- file_selector_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface]
- file_selector_windows 0.9.3+4 [cross_file file_selector_platform_interface flutter]
- firebase_app_check_platform_interface 0.2.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_app_check_web 0.2.0+15 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins web]
- firebase_auth_platform_interface 8.1.0 [_flutterfire_internals collection firebase_core flutter http meta plugin_platform_interface]
- firebase_auth_web 6.0.1 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- firebase_core_platform_interface 6.0.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 3.0.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_messaging_platform_interface 4.7.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 4.0.0 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- firebase_storage_platform_interface 5.2.11 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 3.10.18 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http meta web]
- fixnum 1.1.1
- flutter_plugin_android_lifecycle 2.0.29 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- frontend_server_client 4.0.0 [async path]
- geoclue 0.1.1 [dbus meta]
- geolocator_android 5.0.2 [flutter geolocator_platform_interface meta uuid]
- geolocator_apple 2.3.13 [flutter geolocator_platform_interface]
- geolocator_linux 0.2.3 [dbus flutter geoclue geolocator_platform_interface gsettings package_info_plus]
- geolocator_platform_interface 4.2.6 [flutter plugin_platform_interface vector_math meta]
- geolocator_web 4.1.3 [flutter flutter_web_plugins geolocator_platform_interface web]
- geolocator_windows 0.2.5 [flutter geolocator_platform_interface]
- glob 2.1.3 [async collection file path string_scanner]
- google_identity_services_web 0.3.3+1 [meta web]
- google_sign_in_android 7.0.3 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 6.1.0 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 3.0.0 [flutter plugin_platform_interface]
- google_sign_in_web 1.0.0 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web]
- graphs 2.3.2 [collection]
- gsettings 0.2.8 [dbus xdg_directories]
- hotreloader 4.3.0 [collection logging path stream_transform vm_service watcher]
- html 0.15.6 [csslib source_span]
- http_multi_server 3.2.2 [async]
- http_parser 4.1.2 [collection source_span string_scanner typed_data]
- image_picker_android 0.8.12+25 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.6 [flutter flutter_web_plugins image_picker_platform_interface mime web]
- image_picker_ios 0.8.12+2 [flutter image_picker_platform_interface]
- image_picker_linux 0.2.1+2 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_macos 0.2.1+2 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_platform_interface 2.10.1 [cross_file flutter http plugin_platform_interface]
- image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface]
- io 1.0.5 [meta path string_scanner]
- js 0.7.2
- leak_tracker 10.0.9 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.9 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 6.0.0
- logging 1.3.0
- matcher 0.12.17 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.16.0
- nested 1.0.0 [flutter]
- package_config 2.2.0 [path]
- package_info_plus_platform_interface 3.2.1 [flutter meta plugin_platform_interface]
- path 1.9.1
- path_parsing 1.1.0 [meta vector_math]
- path_provider_android 2.2.17 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.1 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- permission_handler_android 13.0.1 [flutter permission_handler_platform_interface]
- permission_handler_apple 9.4.7 [flutter permission_handler_platform_interface]
- permission_handler_html 0.1.3+5 [flutter flutter_web_plugins permission_handler_platform_interface web]
- permission_handler_platform_interface 4.3.0 [flutter meta plugin_platform_interface]
- permission_handler_windows 0.2.1 [flutter permission_handler_platform_interface]
- petitparser 6.1.0 [meta collection]
- platform 3.1.6
- plugin_platform_interface 2.1.8 [meta]
- pool 1.5.1 [async stack_trace]
- posix 6.0.3 [ffi meta path]
- provider 6.1.5 [collection flutter nested]
- pub_semver 2.2.0 [collection]
- pubspec_parse 1.5.0 [checked_yaml collection json_annotation pub_semver yaml]
- riverpod_analyzer_utils 0.5.10 [analyzer collection crypto custom_lint_core freezed_annotation meta path source_span]
- share_plus_platform_interface 6.1.0 [cross_file flutter meta mime plugin_platform_interface path_provider uuid]
- shared_preferences_android 2.4.11 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.4 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.3 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- shelf 1.4.2 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 3.0.0 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.0
- source_gen 2.0.0 [analyzer async build dart_style glob path pub_semver source_span yaml]
- source_helper 1.3.7 [analyzer source_gen]
- source_span 1.10.1 [collection path term_glyph]
- sprintf 7.0.0
- stack_trace 1.12.1 [path]
- state_notifier 1.0.0 [meta]
- stream_channel 2.1.4 [async]
- stream_transform 2.1.1
- string_scanner 1.4.1 [source_span]
- synchronized 3.4.0
- term_glyph 1.2.2
- test_api 0.7.4 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- timing 1.0.2 [json_annotation]
- tuple 2.0.2
- typed_data 1.4.0 [collection]
- url_launcher_android 6.3.17 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.3 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.2 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.4.1 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.4 [flutter url_launcher_platform_interface]
- vector_graphics 1.1.19 [flutter http vector_graphics_codec]
- vector_graphics_codec 1.1.13
- vector_graphics_compiler 1.1.17 [args meta path path_parsing vector_graphics_codec xml]
- vector_math 2.1.4
- video_player_android 2.8.11 [flutter video_player_platform_interface]
- video_player_avfoundation 2.8.3 [flutter video_player_platform_interface]
- video_player_platform_interface 6.4.0 [flutter plugin_platform_interface]
- video_player_web 2.4.0 [flutter flutter_web_plugins video_player_platform_interface web]
- vm_service 15.0.0
- wakelock_plus 1.3.2 [flutter flutter_web_plugins meta wakelock_plus_platform_interface win32 dbus package_info_plus web]
- wakelock_plus_platform_interface 1.2.3 [flutter plugin_platform_interface meta]
- watcher 1.1.2 [async path]
- web 1.1.1
- web_socket 1.0.1 [web]
- web_socket_channel 3.0.3 [async crypto stream_channel web web_socket]
- win32 5.14.0 [ffi]
- xdg_directories 1.1.0 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.3 [collection source_span string_scanner]

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions