ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
14.2k stars 831 forks source link

emscripten_sleep does not work becuase the native setTimeout is overwritten #611

Open maggch97 opened 11 months ago

maggch97 commented 11 months ago
function setTimeout(timeout) {
  Module["timeout"] = timeout;
}

function safeSetTimeout(func, timeout) {
    return setTimeout(()=>{ // will call the wrong function
        callUserCallback(func)
    }
    , timeout)
}
function _emscripten_sleep(ms) {
    return Asyncify.handleSleep(wakeUp=>safeSetTimeout(wakeUp, ms))
}

Have this problem because I use emscripten_sleep in ffmpeg code. It's better to rename the setTimeout function to other name.