http icon indicating copy to clipboard operation
http copied to clipboard

"JavaCronetEngine: using the fallback Cronet Engine implementation"

Open lukehutch opened this issue 1 year ago • 6 comments

I get the following error when trying to use Cronet in my Flutter application:

W/JavaCronetEngine(17661): using the fallback Cronet Engine implementation. Performance will suffer and many HTTP client features, including caching, will not work.

No actual reason for the failure to instantiate the native Cronet engine is given.

I try to instantiate Cronet using:

    if (Platform.isAndroid) {
      final engine = CronetEngine.build(
        cacheMode: CacheMode.memory,
        cacheMaxSize: _maxCacheSize,
        enableHttp2: true,
        enableQuic: true,
        userAgent: 'Click',
      );
      return CronetClient.fromCronetEngine(engine);
    }

Expected results

Cronet should work, or if the native Cronet implementation can't be instantiated, a better error message should be shown explaining why.

Flutter Doctor output

Doctor output
$ flutter doctor -v
[✓] Flutter (Channel beta, 3.23.0-0.1.pre, on Fedora Linux 40 (Workstation Edition) 6.8.10-300.fc40.x86_64, locale en_US.utf8)
    • Flutter version 3.23.0-0.1.pre on channel beta at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2feea7a407 (5 weeks ago), 2024-06-06 10:19:10 +0700
    • Engine revision bb10c54666
    • Dart version 3.5.0 (build 3.5.0-180.3.beta)
    • DevTools version 2.36.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/luke/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 18.1.6 (Fedora 18.1.6-3.fc40)
    • cmake version 3.28.2
    • ninja version 1.11.1
    • pkg-config version 2.1.0

[✓] Android Studio (version 2023.3)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 79.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.91.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.93.20240702

[✓] VS Code (version 1.90.0-insider)
    • VS Code at /usr/share/code-insiders
    • Flutter extension version 3.91.20240529

[✓] Connected device (3 available)
    • Pixel 7 Pro (mobile) • 29161FDH300BLP • android-arm64  • Android 14 (API 34)
    • Linux (desktop)      • linux          • linux-x64      • Fedora Linux 40 (Workstation Edition) 6.8.10-300.fc40.x86_64
    • Chrome (web)         • chrome         • web-javascript • Google Chrome 125.0.6422.112

[✓] Network resources
    • All expected network resources are available.

• No issues found!

lukehutch avatar Jul 15 '24 10:07 lukehutch

Was the "Pixel 7 Pro" the target device that generated that log message?

brianquinlan avatar Oct 17 '24 20:10 brianquinlan

Yes, I believe so, but this was a long time ago, so I don't remember. If not, it was on the emulator.

lukehutch avatar Oct 17 '24 20:10 lukehutch

I just wanted to verify that you have play services installed on your device - a Google device will have them installed for sure (unless you replaced the OS) ;-)

brianquinlan avatar Oct 17 '24 21:10 brianquinlan

Yes, the Pixel 7 Pro has the stock version of Android. I don't mess with custom OS images anymore :)

lukehutch avatar Oct 17 '24 22:10 lukehutch

Maybe a good first step would be improving the error message to give more info on the cause?

lukehutch avatar Oct 17 '24 22:10 lukehutch

The error comes from the cronet implementation: https://chromium.googlesource.com/chromium/src/+/lkgr/components/cronet/android/java/src/org/chromium/net/impl/JavaCronetEngine.java?autodive=0%2F%2F#116

brianquinlan avatar Oct 17 '24 23:10 brianquinlan