alphacep / vosk-flutter

Apache License 2.0
50 stars 30 forks source link

Example app FATAL EXCEPTION: Data cannot occupy more than 10240 bytes when serialized #16

Open wunderbrick opened 11 months ago

wunderbrick commented 11 months ago

Hello,

Thank you for this incredible software!

As for the issue, I keep getting the following exception when running the example Android Flutter app:

E/AndroidRuntime(10886): FATAL EXCEPTION: WM.task-2 E/AndroidRuntime(10886): Process: com.android.statementservice, PID: 10886 E/AndroidRuntime(10886): java.lang.IllegalStateException: Data cannot occupy more than 10240 bytes when serialized E/AndroidRuntime(10886): at androidx.work.Data.toByteArrayInternal(Data.java:407) E/AndroidRuntime(10886): at androidx.work.Data$Builder.build(Data.java:957) E/AndroidRuntime(10886): at androidx.work.OverwritingInputMerger.merge(OverwritingInputMerger.java:44) E/AndroidRuntime(10886): at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:224) E/AndroidRuntime(10886): at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:140) E/AndroidRuntime(10886): at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91) E/AndroidRuntime(10886): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) E/AndroidRuntime(10886): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) E/AndroidRuntime(10886): at java.lang.Thread.run(Thread.java:1012)

Things seem to work okay even after the exception in the example app.

A bit of an aside, maybe, but I am using the package in another app I'm building and frequently run into this. Occasionally my app will freeze up, and I suspect it might have something to do with this exception. I can't quite pin down the exact cause of the freezing there though, but it is a lead.

I have never done Android development without Flutter, so sadly I'm not sure I can be much assistance in resolving this.

Here is my flutter doctor -v output:

[✓] Flutter (Channel stable, 3.10.6, on macOS 13.4.1 22F770820d darwin-arm64, locale en-US)
    • Flutter version 3.10.6 on channel stable at /Users/awp/code/bin/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (3 weeks ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/awp/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.80.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.71.20230801

[✓] Connected device (2 available)
    • Pixel 4a 5G (mobile) • 0B171JECB21218 • android-arm64  • Android 13 (API 33)
    • Chrome (web)         • chrome         • web-javascript • Google Chrome 115.0.5790.114

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

• No issues found!
sergsavchuk commented 11 months ago

Hello, It looks like the problem is related to the WorkManager used to load the model in a separate thread. In fact, I replaced the current implementation with FFI in https://github.com/alphacep/vosk-flutter/tree/feat/android-ffi , but haven't yet merged it to master. You could give it a try.

wunderbrick commented 11 months ago

I will give it a try when I get a chance. Thank you!