[Bug]: device_info_plus breaks on build web --release --dart2js-optimization O4
Platform
Web
Plugin
device_info_plus
Version
4.0.1
Flutter SDK
3.1.0-9.0.pre
Steps to reproduce
- Invoke
webBrowserInfogetter in any way
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
final info = await deviceInfo.deviceInfo;
final map = info.toMap();
- Build release
$ flutter build web --release --dart2js-optimization O4 --web-renderer html
- Catch
UnimplementedErrorUnimplementedError: 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!
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.
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-optimizationdoes, but I suspect that what is happening is thatDeviceInfoPlusPluginclass fromdevice_info_plus_web.dartgets 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)
Thanks for the info! Just in case, the issue you mention is about Java Proguard optimizations on Android, not the dart2js optimization.
Facing the same issue. Can't access the browser info in release mode but can in debug mode.
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