-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Fix performance issues with seeking while audio is playing #2045
Conversation
It should probably be removed, but did you run the javascript profiler on your code to confirm that the calls to play() and pause() are slow? It's been 6 years so the original issue with mediaelement is probably fixed and we can remove the play/pause calls |
I haven't run a profiler. What happens is that if you play and pause too fast one after the other, you get errors If you do make sure My benchmark was that in the last secnario you can make many more seeks while the audio isn't playing, compared to when it is playing, and assumed that it's because it's not making the play/pause calls and waiting for them to resolve inside. |
i'd definitely check this against a bunch of browsers and html-audio vs media-element combos. iOS/Safari tends towards "wildly different in behavior" vs firefox/chrome |
BTW if you want high performance you should be using WebAudio instead of MediaElement. I assume you want to allow users to seek by dragging the cursor with the mouse during playback? With WebAudio you have more fine control over audio buffers etc which is needed for something like that. |
Works fine on Safari 13.1.2 (15609.3.5.1.3) over here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @todoroff. I think we should give it a try; less is more. Can you add a changelog entry?
…#2045) * fix seekTo performance issues while playing audio
…#2045) * fix seekTo performance issues while playing audio
When making calls to the
seekTo
method while the audio is playing, we were experiencing a issues with console errors and performance (to the point of the UI becoming completely unresponsive in the case of high-frequency seeking) because of unnecessary calls tostart
andpause
inside that method.Making the
seekTo
methodasync
and awaiting the calls topause
andstart
inside solved the errors and the performance hit for low-frequency seeks (less than ~3 seeks per second) but wasn't good enough for higher-frequency seeking due to too much delay to resolve the promises.We finally decided to remove those calls altogether, because they appear to be redundant. They were first introduced in #918, and supposedly solved an issue with backward seeking on
MediaElement
, which I wasn't able to replicate (tested with a 30 min long .ogg file).