I try to do simple thing:
- Call
Player::clear() to stop current audio track
- Immediately after that I call
Player::append() to play new track
if !player.empty() {
player.clear();
}
player.append(sound);
It works fine on linux/windows, but it deadlocks my app thread in WASM.
I have a guess why: inside append there is call to sleep_until_end. sleep_until_end does std::sync::mpsc::Receiver::recv inside of it. And recv blocks calling thread. It causes no issues in linux/windows, because rodio lives in separate thread. But in wasm we have single thread for all things and recv blocks it.
(playing sound on empty Player in WASM works fine)
I try to do simple thing:
Player::clear()to stop current audio trackPlayer::append()to play new trackIt works fine on linux/windows, but it deadlocks my app thread in WASM.
I have a guess why: inside
appendthere is call tosleep_until_end.sleep_until_enddoesstd::sync::mpsc::Receiver::recvinside of it. Andrecvblocks calling thread. It causes no issues in linux/windows, because rodio lives in separate thread. But in wasm we have single thread for all things andrecvblocks it.(playing sound on empty
Playerin WASM works fine)