Open kmod-midori opened 3 years ago
I think it's reasonable that errors aren't reported in the initial call if you requested it not to load, but you should still be able to catch the error either by a later explicit call to load or by listening to errors on the playbackState stream.
Is is unexpected that it doesn't automatically skip to the next item though.
The fact that the error is never reported to playbackStateStream
and automatic skip does not work suggests that the Java side of the plugin might also missed the exception.
Sorry I realised I should have said the playbackEventStream.
That one does not work either.
https://github.com/ryanheise/just_audio/blob/e37b50d6cd6fcca8108cf083ff3bddd400c37acc/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java#L250-L265
Since we have E/AudioPlayer(19603): TYPE_SOURCE: Unable to connect
, it is sure that we have reached there, and the stream listener has been registered on the Dart side (verified with breakpoints). So the error message somehow got lost in the channel?
After these lost errors, the player is unable to play anything when seeked to, even the valid files. It do start working on valid files if I pause and play again, and errors are reported normally from now on. This bug seems only happen if the initial file is unplayable?
sendError only sends the error if the event sink is not null. It's unlikely it would be null though, it would mean it tries to send an error too soon, before the event sink is initialised. On the other end, the error won't be received unless you're already listening to it before the error happens. Again, probably unlikely for this to go wrong either but there are the first two things I would check. Otherwise, maybe there's an unlogged exception happening somewhere within the plugin where it's crashing silently added failing to deliver the sent error. In that case the code needs extra try/catch logging.
sendError
is very likely actually called, but I'm unsure if the event sink is fine.
In that case I'll need to debug the Android side then. Is this possible in Android Studio? I usually use VSCode for all my Flutter works.
They're all just text files after all. I use plain old Vim to edit everything so any other editor that can edit files should work.
Further debugging shows that sendError
is indeed called and the eventSink
is not null. So for some reason the error did not get through?
Putting breakpoint on the onError
callback of platform.playbackEventMessageStream
yields nothing, indicating that it is not called.
The player only returns to normal if I:
If I tell Android Studio to pause on all exceptions, the connection error caused by connecting to the invalid URL keeps popping up, which means that the player looks never stopped (but it is released with Release c9886bb [ExoPlayerLib/2.13.1] [polaris, MIX 2S, Xiaomi, 29] [goog.exo.core]
?)
Which API doesn't behave as documented, and how does it misbehave?
player.setAudioSource
withpreload: false, initialIndex: ...
. When trying to play an invalid URL in this way, errors are never reported to the application and the player does not automatically jump to the next item.Minimal reproduction project https://github.com/chengyuhui/just_audio/tree/error-flood Replaced URLs to invalid ones with additional change on L81, disabling preload with
initialIndex
.To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
Error messages
Notice that neither
A stream error occurred
norError loading playlist
is here.Expected behavior The player should advance to the next item, and this error should be added to
playbackEventStream
or thrown.Smartphone (please complete the following information):
Flutter SDK version
Additional context The whole error handling situation seems to be hit-or-miss, maybe we need some general way to improve it?