plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

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

Open nikto-b opened this issue 3 years ago • 11 comments

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 avatar Jul 20 '22 13:07 nikto-b

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.

miquelbeltran avatar Jul 31 '22 13:07 miquelbeltran

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)

nikto-b avatar Aug 01 '22 12:08 nikto-b

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

miquelbeltran avatar Aug 01 '22 13:08 miquelbeltran

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

billthecoder046 avatar Dec 07 '22 10:12 billthecoder046

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[bot] avatar Mar 08 '23 00:03 github-actions[bot]