-
Notifications
You must be signed in to change notification settings - Fork 29
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(android): promises leak caused by player not in the HashMap #136
fix(android): promises leak caused by player not in the HashMap #136
Conversation
Do I need to enter a ticket for this PR, or can we merge it as it is? |
We need to manage the seekTo function with a try-catch block because we do not initialize the player until the user starts playing. Therefore, when the user attempts to seek before the player is initialized, it will reject the promise. To handle this, Please add the necessary changes here as shown below.
|
a185bf0
to
45988e7
Compare
@nilesh-simform I used what you proposed coupled with I'm sure there is a better fix for that, but at least this will unblock the user, and later on, it can be fixed better. |
Closing this in favour of #138 |
After calling
stopAllPlayers,
if we call some Android native function and the player is not in the HashMap, multiple functions will forget to reject the promise and end up with promise leaks. This is affectingstartPlayer
,pausePlayer
,seekToPlayer
,setVolume
,getDuration
Below is an example where the console log after
await AudioWaveform.startPlayer
never shows since the call leaked the promiseSTR:
useAudioPlayer.stopAllPlayers()
useAudioPlayer.startPlayer()
never returnsOnce the promise is rejected correctly, the error is propagated to the JS correctly, proof: