From 602ce76d3d422842c60d2a6e240ef2fe8d346140 Mon Sep 17 00:00:00 2001 From: marcusstenbeck Date: Fri, 20 Jan 2017 13:25:29 +0100 Subject: [PATCH] fix(html5-playback): remove setTimeout() call that caused loss of call stack On mobile, the play event needs to be triggered by a user gesture. By setting a timeout the call stack containing the user tap gesture is lost. Since this was added way back to support something in Firefox 13 it could most likely be removed without negative impact. #609 --- src/howler.core.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/howler.core.js b/src/howler.core.js index afd8e6df..1ed69eb5 100644 --- a/src/howler.core.js +++ b/src/howler.core.js @@ -736,18 +736,16 @@ node.volume = sound._volume * Howler.volume(); node.playbackRate = sound._rate; - setTimeout(function() { - node.play(); + node.play(); - // Setup the new end timer. - if (timeout !== Infinity) { - self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout); - } + // Setup the new end timer. + if (timeout !== Infinity) { + self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout); + } - if (!internal) { - self._emit('play', sound._id); - } - }, 0); + if (!internal) { + self._emit('play', sound._id); + } }; // Play immediately if ready, or wait for the 'canplaythrough'e vent.