Tau: [BUG] Android audio playback Non-positive period

Created on 22 Jul 2020  路  11Comments  路  Source: Canardoux/tau

Flutter Sound Version :

5.1.1

  • Released or Beta version ?
    Released
  • Version number ?
    flutter 1.17.5

  • FULL or LITE flavor ?
    FULL and LITE

  • Result of the command "flutter pub deps | grep flutter_sound"
    (very important)

FlutterSoundPlayer _flutterSoundPlayer = FlutterSoundPlayer();
await _flutterSoundPlayer.openAudioSession();
await _flutterSoundPlayer.startPlayer(
            fromURI: (await recording.audioFile).path);
_progressSubscription =
            _flutterSoundPlayer.onProgress.listen(_audioPlayerListener);

Severity

  • Crash

Platforms you faced the error

  • Android
  • Real device

    Samsung S8

Logs

(This is very important. Most of the time we cannot do anything if we do not have information on your bug)

I/flutter (25448): FS:---> openAudioSession
D/AudioManager(25448): setBluetoothScoOn false
D/AudioManager(25448): setSpeakerphoneOn true
D/AudioManager(25448): setSpeakerphoneOn true
D/AudioManager(25448): setBluetoothScoOn true
I/flutter (25448): FS:<--- openAudioSession
I/flutter (25448): play
I/flutter (25448): FS:---> startPlayer
I/flutter (25448): FS:---> stop
I/flutter (25448): FS:<--- stop
I/flutter (25448): FS:---> _convert
I/flutter (25448): FS:---> needToConvert
I/flutter (25448): FS:<--- needToConvert
I/flutter (25448): FS:<--- _convert
I/MediaPlayer(25448): Need to enable context aware info
V/MediaPlayer-JNI(25448): native_setup
V/MediaPlayerNative(25448): constructor
V/MediaPlayerNative(25448): setListener
V/MediaPlayer-JNI(25448): setDataSourceFD: fd 93
V/MediaPlayerNative(25448): setDataSource(93, 0, 576460752303423487)
V/MediaPlayerNative(25448): setVideoSurfaceTexture
V/MediaPlayerNative(25448): prepare
V/MediaPlayerNative(25448): message received msg=200, ext1=10973, ext2=0
W/MediaPlayerNative(25448): info/warning (10973, 0)
V/MediaPlayerNative(25448): callback application
V/MediaPlayerNative(25448): back from callback
V/MediaPlayerNative(25448): message received msg=1, ext1=0, ext2=0
V/MediaPlayerNative(25448): MediaPlayer::notify() prepared
V/MediaPlayerNative(25448): signal application thread
V/MediaPlayerNative(25448): callback application
V/MediaPlayerNative(25448): prepare complete - status=0
V/MediaPlayerNative(25448): back from callback
V/MediaPlayerNative(25448): invoke 68
V/MediaPlayer-JNI(25448): getCurrentPosition: 0 (msec)
V/MediaPlayerNative(25448): invoke 68
I/flutter (25448): FS:<--- startPlayer
D/FlutterSoundPlugin(25448): mediaPlayer prepared and start
V/MediaPlayer-JNI(25448): start
V/MediaPlayerNative(25448): start
I/flutter (25448): dismissOverlay
V/MediaPlayerNative(25448): message received msg=300, ext1=0, ext2=0
V/MediaPlayerNative(25448): Received SEC_MM_PLAYER_CONTEXT_AWARE
V/MediaPlayerNative(25448): callback application
V/MediaPlayerNative(25448): back from callback
D/AndroidRuntime(25448): Shutting down VM
E/AndroidRuntime(25448): FATAL EXCEPTION: main
E/AndroidRuntime(25448): java.lang.IllegalArgumentException: Non-positive period.
E/AndroidRuntime(25448):    at java.util.Timer.schedule(Timer.java:254)
E/AndroidRuntime(25448):    at com.dooboolab.fluttersound.FlutterSoundPlayer.onPrepared(FlutterSoundPlayer.java:462)
E/AndroidRuntime(25448):    at com.dooboolab.fluttersound.FlutterSoundPlayer.lambda$startPlayer$0$FlutterSoundPlayer(FlutterSoundPlayer.java:375)
E/AndroidRuntime(25448):    at com.dooboolab.fluttersound.-$$Lambda$FlutterSoundPlayer$CKEELXPVh5rkG3TIOBhd8o5Vky8.onPrepared(Unknown Source:4)
E/AndroidRuntime(25448):    at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:4238)
E/AndroidRuntime(25448):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(25448):    at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(25448):    at android.app.ActivityThread.main(ActivityThread.java:7050)
E/AndroidRuntime(25448):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(25448):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/AndroidRuntime(25448):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
I/Process (25448): Sending signal. PID: 25448 SIG: 9
Lost connection to device.

maybe bug

All 11 comments

I am having the same problem. And yes, I am doing player.setSubscriptionDuration(Duration(milliseconds: 100));. Works on iOS but not android.

I/flutter (30828): FS:---> openAudioSession 
I/flutter (30828): FS:<--- openAudioSession 
I/flutter (30828): FS:---> startPlayer 
I/flutter (30828): FS:---> stop 
I/flutter (30828): FS:<--- stop 
I/flutter (30828): FS:---> _convert 
I/flutter (30828): FS:---> needToConvert 
I/flutter (30828): FS:<--- needToConvert 
I/flutter (30828): FS:<--- _convert 
I/flutter (30828): FS:<--- startPlayer 
D/FlutterSoundPlugin(30828): mediaPlayer prepared and start
D/AndroidRuntime(30828): Shutting down VM
I/flutter (30828): FS:---> setVolume 
E/AndroidRuntime(30828): FATAL EXCEPTION: main
E/AndroidRuntime(30828): Process: story.crafting.app, PID: 30828
E/AndroidRuntime(30828): java.lang.IllegalArgumentException: Non-positive period.
E/AndroidRuntime(30828):    at java.util.Timer.schedule(Timer.java:254)
E/AndroidRuntime(30828):    at com.dooboolab.fluttersound.FlutterSoundPlayer.onPrepared(FlutterSoundPlayer.java:462)
E/AndroidRuntime(30828):    at com.dooboolab.fluttersound.FlutterSoundPlayer.lambda$startPlayer$0$FlutterSoundPlayer(FlutterSoundPlayer.java:375)
E/AndroidRuntime(30828):    at com.dooboolab.fluttersound.-$$Lambda$FlutterSoundPlayer$CKEELXPVh5rkG3TIOBhd8o5Vky8.onPrepared(Unknown Source:4)
E/AndroidRuntime(30828):    at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:3367)
E/AndroidRuntime(30828):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(30828):    at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(30828):    at android.app.ActivityThread.main(ActivityThread.java:6680)
E/AndroidRuntime(30828):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(30828):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime(30828):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I/Process (30828): Sending signal. PID: 30828 SIG: 9
Lost connection to device.

Figured it out! I just needed to change:

player.setSubscriptionDuration(Duration(milliseconds: 100));
to
await player.setSubscriptionDuration(Duration(milliseconds: 100));

and it worked.

It seems that FS has a concurrency bug, here.
I will try to figure what, before the 6.0 release, in a few weeks. Please stay tuned.

Note: adding await was a rich idea. Asynchronous processing in Flutter is a real bug net. Better to stay far from this horrible dart feature.
Please keep this issue open

@jayabrown where did you put the setSubscriptionDuration?

@Larpoux This problem actually happened quite frequently especially when I'm playing something during a recording.

I am sorry, Tony, that you have crashes with FS.
I worked a little bit to fix some race conditions in the future Flutter Sound 6.0 and it could eventually fix your problems.
I do not know precisely what is the state of your project : in development or deployed ?
If in development, perhaps you could try a beta version of Flutter Sound V6 : I am actually completely overbooked and I would prefer not to do maintenance on V5.0, ...if possible... and I want to add some new features in V6, before release it.
The beta V6.0 can be find in this fork

Thank you for your help and your time!
I'll let you know if it works.

If you try the Beta V6, you will have to delete the Podfile.lock and recreate it with

$ pod install

as explained in the migration notice

It works well on android!

This is really good news. 馃槃

V6.0 is released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kiha-la picture kiha-la  路  5Comments

TharinduNM picture TharinduNM  路  6Comments

deepbluev7 picture deepbluev7  路  5Comments

farrelanelca picture farrelanelca  路  5Comments

satyajitghana picture satyajitghana  路  3Comments