Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions patches/howler/details.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `howler` patches

### [howler+2.2.4+001+catch-audio-context-resume-rejection.patch](howler+2.2.4+001+catch-audio-context-resume-rejection.patch)

- Reason:

```
Howler calls `AudioContext.resume()` in the audio unlock handler and in `_autoResume()` without handling a rejected promise.
iOS Safari rejects it with `InvalidStateError: Failed to start the audio device` when it can't start the audio session
(for example, during a phone call or while another app holds the audio session), which surfaces as an unhandled promise rejection.
This patch adds no-op rejection handlers. Howler only sets its state to 'running' after a successful resume, so the next play() still retries.
```

- Upstream PR/issue: https://github.com/goldfire/howler.js/issues/1743, https://github.com/goldfire/howler.js/pull/1764
- E/App issue: https://github.com/Expensify/App/issues/102744
- PR introducing patch: https://github.com/Expensify/App/pull/102795
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/node_modules/howler/dist/howler.js b/node_modules/howler/dist/howler.js
--- a/node_modules/howler/dist/howler.js
+++ b/node_modules/howler/dist/howler.js
@@ -382,7 +382,9 @@

// Calling resume() on a stack initiated by user gesture is what actually unlocks the audio on Android Chrome >= 55.
if (typeof self.ctx.resume === 'function') {
- self.ctx.resume();
+ // The browser can refuse to start the audio device (for example, iOS Safari while another app holds the audio session).
+ // Swallow the rejection so it doesn't surface as an unhandled promise rejection.
+ self.ctx.resume().catch(function() {});
}

// Setup a timeout to check that we are unlocked on the next event loop.
@@ -529,7 +531,9 @@
for (var i=0; i<self._howls.length; i++) {
self._howls[i]._emit('resume');
}
- });
+ }).catch(function() {
+ // The browser refused to start the audio device. Keep the state as suspended so the next play() tries to resume again.
+ });

if (self._suspendTimer) {
clearTimeout(self._suspendTimer);
Loading