Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase_analytics] - Web: Unable to load plugin when uBlock is on, doesn't fail gracefully #3531

Closed
bradcypert opened this issue Sep 12, 2020 · 4 comments
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: analytics type: bug Something isn't working type: crash A compile error or crash

Comments

@bradcypert
Copy link

bradcypert commented Sep 12, 2020

Bug report

Describe the bug
In web browsers with heavy privacy blocking (Chome/Firefox with UBlock, Brave Browser), Firebase Analytics fails to load. Additionally, it bubbles it's error all the way up to the dart engine and, from what I can tell, isn't something I can catch or modify due to it being generated in generated_plugin_registrant. This results in a white page (nothing loads) and a console error on my Flutter web site (https://my.lunajournal.app).

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to 'https://my.lunajournal.app' in a browser with ublock (or similar privacy tooling)
  2. Open browser web console
  3. Observe console error, blank screen

Stacktrace attached:

Uncaught Error: undefined
    V7 main.dart.js:16263
    s async_patch.dart:315
    $2 async_patch.dart:340
    Z async_patch.dart:245
    V7 main.dart:8
    <anonymous> main.dart.js:79056
    <anonymous> main.dart.js:79051
    dartProgram main.dart.js:79054
    <anonymous> main.dart.js:79056
js_helper.dart:1129:36

Expected behavior

Even if analytics fail to load, I'd expect the remainder of the site to be functional. If that isn't possible, I'd expect a way to disable analytics for web builds while keeping them around for iOS and Android.


Additional context

Add any other context about the problem here.


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 beta, 1.21.0-9.2.pre, on Mac OS X 10.15.5 19F101, locale en-US)

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.7)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[!] IntelliJ IDEA Ultimate Edition (version 2019.2.3)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.47.3)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)

! Doctor found issues in 3 categories.

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.10.0-7.3.beta
Flutter SDK 1.21.0-9.2.pre
luna_journal 1.0.0+1

dependencies:
- apple_sign_in 0.1.0 [flutter]
- cloud_firestore 0.13.7 [flutter meta firebase_core cloud_firestore_platform_interface cloud_firestore_web]
- cupertino_icons 0.1.3
- firebase_analytics 5.0.16 [meta flutter firebase_analytics_web firebase_analytics_platform_interface]
- firebase_auth 0.16.1 [meta firebase_core firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.4.5 [firebase_core_platform_interface flutter meta firebase_core_web]
- fluro 1.6.3 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- google_sign_in 4.5.3 [google_sign_in_platform_interface flutter meta google_sign_in_web]
- hive 1.4.4 [meta crypto]
- hive_flutter 0.3.1 [flutter hive path_provider path]
- icons_helper 1.0.4 [flutter font_awesome_flutter flutter_driver]
- provider 4.3.2+1 [flutter nested collection]
- url_launcher 5.5.2 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos]
- zefyr 0.11.0 [flutter collection url_launcher quill_delta notus meta quiver_hashcode]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- archive 2.0.13 [crypto args path]
- args 1.6.0
- async 2.5.0-nullsafety [collection]
- boolean_selector 2.1.0-nullsafety [source_span string_scanner]
- characters 1.1.0-nullsafety.2
- charcode 1.2.0-nullsafety
- clock 1.1.0-nullsafety
- cloud_firestore_platform_interface 1.1.2 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.1.1+2 [flutter flutter_web_plugins firebase http_parser meta firebase_core cloud_firestore_platform_interface js]
- collection 1.15.0-nullsafety.2
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- fake_async 1.1.0-nullsafety [clock collection]
- file 5.2.1 [intl meta path]
- firebase 7.3.0 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_auth_platform_interface 1.1.8 [flutter meta plugin_platform_interface]
- firebase_auth_web 0.1.3+1 [firebase_auth_platform_interface flutter flutter_web_plugins firebase http_parser meta js]
- firebase_core_platform_interface 1.0.4 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.1.1+2 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_driver 0.0.0 [file json_rpc_2 meta path web_socket_channel vm_service_client webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypto fake_async intl matcher platform process pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- font_awesome_flutter 8.8.1 [flutter]
- fuchsia_remote_debug_protocol 0.0.0 [json_rpc_2 process web_socket_channel flutter_test flutter_driver archive args async boolean_selector charcode clock collection convert crypto fake_async file intl matcher meta path platform pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math vm_service_client webdriver]
- google_sign_in_platform_interface 1.1.2 [flutter meta quiver]
- google_sign_in_web 0.9.1+1 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- intl 0.16.1 [path]
- js 0.6.2
- json_rpc_2 2.2.1 [stack_trace stream_channel]
- matcher 0.12.10-nullsafety [stack_trace]
- meta 1.3.0-nullsafety.2
- nested 0.0.4 [flutter]
- notus 0.1.5 [collection meta quill_delta quiver_hashcode]
- path 1.8.0-nullsafety
- path_provider 1.6.14 [flutter path_provider_platform_interface path_provider_macos path_provider_linux]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+3 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- pedantic 1.9.2 [meta]
- platform 2.2.1
- platform_detect 1.4.0 [meta pub_semver]
- plugin_platform_interface 1.0.2 [meta]
- process 3.0.13 [file intl meta path platform]
- pub_semver 1.4.4 [collection]
- quill_delta 1.0.2 [collection quiver_hashcode]
- quiver 2.1.3 [matcher meta]
- quiver_hashcode 2.0.0
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety [path]
- stream_channel 2.1.0-nullsafety [async]
- string_scanner 1.1.0-nullsafety [charcode source_span]
- sync_http 0.2.0
- term_glyph 1.2.0-nullsafety
- test_api 0.2.19-nullsafety [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.2 [collection]
- url_launcher_linux 0.0.1+1 [flutter]
- url_launcher_macos 0.0.1+7 [flutter]
- url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.3+1 [url_launcher_platform_interface platform_detect flutter flutter_web_plugins meta]
- vector_math 2.1.0-nullsafety.2
- vm_service_client 0.2.6+2 [async collection json_rpc_2 pub_semver source_span stack_trace stream_channel web_socket_channel]
- web_socket_channel 1.1.0 [async crypto stream_channel]
- webdriver 2.1.2 [archive matcher path stack_trace sync_http]
- xdg_directories 0.1.2 [meta path process]

@bradcypert bradcypert added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 12, 2020
@TahaTesser TahaTesser added plugin: analytics type: crash A compile error or crash impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) and removed Needs Attention This issue needs maintainer attention. labels Sep 15, 2020
@bradcypert
Copy link
Author

@TahaTesser I'd be happy to help work on this, but I'm not sure where to start. Any pointers?

@Ehesp
Copy link
Member

Ehesp commented Sep 28, 2020

I'm not sure there's much we can do here until we're able to bundle the Firebase code within the compiled Dart code (currently not do-able). We wrap the https://pub.dev/packages/firebase package, which itself assumes Firebase is available.

Other than that, we could look for the firebase global in the window object and check whether it exists.

@bradcypert
Copy link
Author

That makes sense to me. Is it possible to opt out of a plug-in given a build flag? For example, if I'm building for web, ignoring the analytics package would probably be sufficient to get past this.

@bradcypert
Copy link
Author

Referencing here for anyone else who stumbles upon this issue: googlearchive/firebase-dart#335

@firebase firebase locked and limited conversation to collaborators Nov 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: analytics type: bug Something isn't working type: crash A compile error or crash
Projects
None yet
Development

No branches or pull requests

3 participants