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

[Bug]: device_info_plus breaks on build web --release --dart2js-optimization O4 #971

Open
nikto-b opened this issue Jul 20, 2022 · 12 comments
Labels
bug Something isn't working device_info_plus Hacktoberfest Issues taking part in Hacktoberfest missing info Not enough info or not following the issue template Stale web

Comments

@nikto-b
Copy link

nikto-b commented Jul 20, 2022

Platform

Web

Plugin

device_info_plus

Version

4.0.1

Flutter SDK

3.1.0-9.0.pre

Steps to reproduce

  1. Invoke webBrowserInfo getter in any way
                    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
                    final info = await deviceInfo.deviceInfo;
                    final map = info.toMap();
  1. Build release
$ flutter build web --release --dart2js-optimization O4 --web-renderer html
  1. Catch UnimplementedError
    UnimplementedError: webBrowserInfo() has not been implemented.

Code Sample

No response

Logs

There is no way to run with `--release` and `--dart2js-optimization O4` flags, but here is web console logs:

Uncaught UnimplementedError: webBrowserInfo() has not been implemented.
    at Object.c (main.dart.js:3455:3)
    at Z2.ab3 (main.dart.js:35015:15)
    at main.dart.js:35000:15
    at aea.a (main.dart.js:4635:63)
    at aea.$2 (main.dart.js:30376:14)
    at Object.Y (main.dart.js:4621:10)
    at E0.gvt (main.dart.js:35005:10)
    at main.dart.js:35008:33
    at aea.a (main.dart.js:4635:63)
    at aea.$2 (main.dart.js:30376:14)
c	@	main.dart.js:3455
ash	@	main.dart.js:5412
v6	@	main.dart.js:5505
$0	@	main.dart.js:30920
axj	@	main.dart.js:4751
axt	@	main.dart.js:4753
$1	@	main.dart.js:30320
ayX	@	main.dart.js:3536
(anonymous)	@	main.dart.js:3544
childList (async)		
$1	@	main.dart.js:30327
an2	@	main.dart.js:4758
ow	@	main.dart.js:4819
eV	@	main.dart.js:4770
IQ	@	main.dart.js:37594
o6	@	main.dart.js:37592
P	@	main.dart.js:38553
tM	@	main.dart.js:38314
hv	@	main.dart.js:38575
xH	@	main.dart.js:38323
jO	@	main.dart.js:38284
(anonymous)	@	main.dart.js:3577
Vd	@	main.dart.js:38497
$2	@	main.dart.js:38509
a8	@	main.dart.js:30021
Fs	@	main.dart.js:38504
Nw	@	main.dart.js:38502
hV	@	main.dart.js:37650
Ah	@	main.dart.js:37644
Ah	@	main.dart.js:56684
Gm	@	main.dart.js:37638
a7a	@	main.dart.js:37627
xt	@	main.dart.js:37625
Yc	@	main.dart.js:37621
(anonymous)	@	main.dart.js:3577
QU	@	main.dart.js:966
a_z	@	main.dart.js:25402
(anonymous)	@	main.dart.js:3577
$1	@	main.dart.js:25577
$1	@	main.dart.js:25540
$1	@	main.dart.js:25416
ayX	@	main.dart.js:3536
(anonymous)	@	main.dart.js:3544



### Flutter Doctor

```shell
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, 3.1.0-9.0.pre, on Arch Linux 5.18.9, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Community Edition (version 2022.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!
@nikto-b nikto-b added bug Something isn't working triage labels Jul 20, 2022
@miquelbeltran
Copy link
Member

Just to confirm, this doesn't happen on debug, correct?

Does it happen when you remove the dart2js optimization?

Does it happen with other levels of optimization?

I don't fully know what dart2js-optimization does, but I suspect that what is happening is that DeviceInfoPlusPlugin class from device_info_plus_web.dart gets lost during the optimization.

@nikto-b
Copy link
Author

nikto-b commented Aug 1, 2022

Just to confirm, this doesn't happen on debug, correct?

Does it happen when you remove the dart2js optimization?

Does it happen with other levels of optimization?

I don't fully know what dart2js-optimization does, but I suspect that what is happening is that DeviceInfoPlusPlugin class from device_info_plus_web.dart gets lost during the optimization.

  • this doesn't happen on debug
  • still failing with no dart2js optimization
  • works on O2 optimization

AFAIK, dart2js optimizations can cut off some parts of generated JS code, this can cause problems with DI (google_maps_flutter was optimized-out in release builds for android about year ago, for example)

@miquelbeltran
Copy link
Member

Thanks for the info! Just in case, the issue you mention is about Java Proguard optimizations on Android, not the dart2js optimization.

@mhadaily mhadaily added the Hacktoberfest Issues taking part in Hacktoberfest label Sep 28, 2022
@billthecoder046
Copy link

Facing the same issue. Can't access the browser info in release mode but can in debug mode.

@github-actions
Copy link

github-actions bot commented Mar 8, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

@github-actions github-actions bot added the Stale label Mar 8, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2023
@mr-stan-dev
Copy link

Facing the same issue. No flags. Just with flutter build web --release

@NITK10CA49
Copy link

i am also facing the same issue. Can't access the browser info in release mode but can in debug mode. This issue raised in july 2022, its 2 years. Is this issue going to be fixed?
or is it working fine with any other older versions.
If it is not supported by web,i am requesting you to remove that support in pub.dev
Thanks Team for your support

@miquelbeltran
Copy link
Member

This is a community effort, there are no companies behind this project, and it is purely voluntary based.

Unfortunately, this seems to need special knowledge on the dart2js compiler, which no one in the maintainer team has, so external help is definitely needed.

@miquelbeltran
Copy link
Member

miquelbeltran commented Aug 22, 2024

Btw, a message says it works with the O2 optimization, so did you try with the --dart2js-optimization O2 flag?

If anyone can check the different optimization levels from O0 to O4 and report back, that would be very useful, and we can add that to the README

@NITK10CA49
Copy link

i am doing with flutter build web --web-renderer canvaskit, i am not sure purpose above optimisation

@miquelbeltran
Copy link
Member

miquelbeltran commented Aug 22, 2024

I ran flutter build web --web-renderer canvaskit on the device_info_plus example project, then went to build/web and started a web server with python3 -m http.server, then I opened http://0.0.0.0:8000/ on my browser.

The app loads correctly.

I repeated the same process with flutter build web --release and I couldn't reproduce the issue.

I cleaned the project to ensure the build folder was empty, and then run flutter build web --release --dart2js-optimization O4 with the highest level of optimization, then I run the project and I couldn't reproduce the issue.

Tested again with flutter build web --release --dart2js-optimization O4 --web-renderer html matching the original post just in case and no issues.

If you still have this issue, please provide a repo with that reproduces the error.

@miquelbeltran miquelbeltran added the missing info Not enough info or not following the issue template label Aug 22, 2024
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

@github-actions github-actions bot added the Stale label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working device_info_plus Hacktoberfest Issues taking part in Hacktoberfest missing info Not enough info or not following the issue template Stale web
Projects
None yet
Development

No branches or pull requests

6 participants