Skip to content

Flutter fail to load on mobile browsers #83176

@espanadebate

Description

@espanadebate

Steps to Reproduce

I'm currently using Github Pages for hosting a WebApp (https://espanadebate.github.io/web/). Loading times aside, there's no issue at all with it in almost every navigator - on PC, it loads properly, and whenever I opened it on mobile everything works fine, but if I use Microsoft Edge app (just vanilla Edge app - on Canary and Dev it works fine) the page doesn't load.

When inspecting with Edge Dev Tools plugging the phone to the PC I found that the error was caused by this line in the default index.html generated when built:

image

This goes in line with the fact that another web I hosted in Pages (https://pspsicologiaweb.github.io/pspsicologiaweb/) with the old default index.html, and with the simpler script:

<script> if ('serviceWorker' in navigator) { window.addEventListener('load', function () { navigator.serviceWorker.register('flutter_service_worker.js?v=1617947039'); }); } </script>

works perfectly fine in all navigators, mobile and desktop.

This has happened, at least, since the Flutter pre-2.2 version (don't remember the exact version, but since I encountered this error, I've upgraded to the current one, so for sure this is at least pre-2.2).

Expected results: App loading

Actual results: App doesn't load

Logs

Verbose

C:\Users\guill\Documents\espanadebate\espanadebate>flutter run --verbose
[ +191 ms] executing: [C:\Users\guill\Documents\flutter/] git -c
log.showSignature=false log -n 1 --pretty=format:%H
[ +141 ms] Exit code 0 from: git -c log.showSignature=false log -n 1
--pretty=format:%H
[   +3 ms] 4d7946a68d26794349189cf21b3f68cc6fe61dcb
[   +3 ms] executing: [C:\Users\guill\Documents\flutter/] git tag --points-at
4d7946a68d26794349189cf21b3f68cc6fe61dcb
[  +83 ms] Exit code 0 from: git tag --points-at
4d7946a68d26794349189cf21b3f68cc6fe61dcb
[   +2 ms] 2.0.3
[  +93 ms] executing: [C:\Users\guill\Documents\flutter/] git rev-parse
--abbrev-ref --symbolic @{u}
[  +70 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +2 ms] origin/stable
[   +1 ms] executing: [C:\Users\guill\Documents\flutter/] git ls-remote
--get-url origin
[  +63 ms] Exit code 0 from: git ls-remote --get-url origin
[   +2 ms] https://github.com/flutter/flutter.git
[ +141 ms] executing: [C:\Users\guill\Documents\flutter/] git rev-parse
--abbrev-ref HEAD
[  +62 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[   +2 ms] stable
[ +177 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required,
skipping update.
[   +3 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required,skipping update.
[   +2 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping
update.
[   +2 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping
update.
[   +9 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skippingupdate.
[   +2 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skippingupdate.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required,
skipping update.
[   +3 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required,
skipping update.
[ +144 ms] executing:
C:\Users\guill\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[  +88 ms] List of devices attached
[  +12 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required,
skipping update.
[   +2 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required,skipping update.
[   +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping
update.
[   +7 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skippingupdate.
[   +2 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skippingupdate.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required,
skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required,
skipping update.
[ +193 ms] Multiple devices found:
[  +44 ms] Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
[   +6 ms] Edge (web)   • edge   • web-javascript • Microsoft Edge 90.0.818.62
[   +5 ms] [1]: Chrome (chrome)
[   +1 ms] [2]: Edge (edge)
[   +6 ms] Please choose one (To quit, press "q/Q")
[   +1 ms] :
[+40079 ms] 1
[  +33 ms] Skipping pub get: version match.
[ +312 ms] Generating
C:\Users\guill\Documents\espanadebate\espanadebate\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[ +220 ms] Launching lib\main.dart on Chrome in debug mode...
[ +311 ms] Updating assets
[ +240 ms] Manifest contained wildcard assets. Inserting missing file into buildgraph to force rerun. for more information see #56466.
[   +9 ms] Waiting for connection from debug service on Chrome...
[ +328 ms] <- reset
[  +18 ms] C:\Users\guill\Documents\flutter\bin\cache\dart-sdk\bin\dart.exe
--disable-dart-dev
C:\Users\guill\Documents\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\Users\guill\Documents\flutter\bin\cache\flutter_web_sdk/ --incremental
--target=dartdevc --debugger-module-names --experimental-emit-debug-metadata
-DFLUTTER_WEB_AUTO_DETECT=true --output-dill
C:\Users\guill\AppData\Local\Temp\flutter_tools.4cde226e\flutter_tool.6be780ba\app.dill --libraries-spec
file:///C:/Users/guill/Documents/flutter/bin/cache/flutter_web_sdk/libraries.json --packages
C:\Users\guill\Documents\espanadebate\espanadebate\.dart_tool\package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts
--track-widget-creation --filesystem-root
C:\Users\guill\AppData\Local\Temp\flutter_tools.4cde226e\flutter_tools.3f3da3ba
--filesystem-scheme org-dartlang-app --initialize-from-dill
build\c7922d95bf4a2462b75c84a97c312edb.cache.dill.track.dill --platform
file:///C:/Users/guill/Documents/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk.dill --no-sound-null-safety
[  +17 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+40826 ms] Waiting for connection from debug service on Chrome... (completed in41,2s)
[   +5 ms] Synced 32.3MB.
[   +2 ms] <- accept
[   +1 ms] Caching compiled dill

ANALYZE

C:\Users\guill\Documents\espanadebate\espanadebate>flutter analyze
Analyzing espanadebate...

   info - Unused import: 'package:espanadebate/widgets/embed.dart' - lib\destinos\torneo.dart:9:8 - unused_import
   info - Name types using UpperCamelCase - lib\widgets\UIfake.dart:1:7 - camel_case_types
   info - Avoid using web-only libraries outside Flutter web plugin packages - lib\widgets\embed.dart:2:1 - avoid_web_libraries_in_flutter
   info - This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: Embed.iframeWidget, Embed.iframeElement, Embed.src - lib\widgets\embed.dart:5:7 - must_be_immutable

4 issues found. (ran in 28.6s)
```
<!-- Finally, paste the output of running `flutter doctor -v` here. -->

**DOCTOR**

```
C:\Users\guill\.AndroidStudio4.0\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel dev, 2.3.0-12.1.pre, on Microsoft Windows [Versión 10.0.19041.985], locale es-ES)
    • Flutter version 2.3.0-12.1.pre at C:\Users\guill\.AndroidStudio4.0\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f9c825981c (4 days ago), 2021-05-18 14:07:52 -0700
    • Engine revision 26e217e6c3
    • Dart version 2.14.0 (build 2.14.0-edge.a527411e5100a0a4f48c4009087a1b988aa784af)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
    • Android SDK at C:\Users\guill\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.0
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin version 48.1.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 90.0.818.62

• No issues found!
Process finished with exit code 0
```

</details>

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listengineflutter/engine related. See also e: labels.found in release: 2.2Found to occur in 2.2found in release: 2.3Found to occur in 2.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions