Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race Condition - Short multiple network requests (<1 second) can cause playing state not being update #1153

Open
rootux opened this issue Jan 2, 2024 · 3 comments
Assignees
Labels
1 backlog bug Something isn't working

Comments

@rootux
Copy link

rootux commented Jan 2, 2024

Trying to play a short audio file.
Than if before getting the call to

          .load(LoadRequest(
...

We get a network request to get another file to be played -
we've stuck in a loop where the state of the player is playing but it is NOT playing and we cannot play new audio files.

This I assume happens due to a race condition the time it takes to load until it plays it

This fixes the issue

just_audio.dart
Line 879:
final duration = await _durationFuture;
I've added below it this patch

      if (duration != null && (duration <= Duration(milliseconds: 1000))) {
        _playingSubject.add(false);
      }

As mentioned this is the solution that worked for me - might be relevant for others

@rootux rootux added 1 backlog bug Something isn't working labels Jan 2, 2024
Copy link

github-actions bot commented Jan 2, 2024

Oops, it appears that your issue did not follow the template and is missing one or more required sections. Please open a new issue, and provide all required sections and information.

FAQ:

  1. Do I really need to submit a minimal reproduction project for a bug? A: Yes. I prioritise bugs secondarily on how many people are affected, and primarily on whether the bug report is complete, in the sense that it enables me to immediately reproduce it and start working on a fix. If a bug is important to you, the best thing you can do is to provide all requested information ASAP so that I can start looking into it ASAP.

  2. I think I supplied all required information, so did the bot make a mistake? A: The bot only checks the section headings, so when you post a new issue, make sure you leave the section headings intact. (Note that because of this, it is even possible to trick the bot by including only the section headings, and then not providing the requested information under each heading. This is frowned upon, and the issue will be closed manually.)

@github-actions github-actions bot closed this as completed Jan 2, 2024
@rootux
Copy link
Author

rootux commented Jan 4, 2024

This is the updated fix (After Line 879):


// This fixes some kind of lock that happens on the play state
      // This fix releases play after duration finished
      if (duration != null) {
        Future.delayed(duration!, () {
          _playingSubject.add(false);
        });
      }

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2024
@ryanheise ryanheise reopened this Oct 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants