Skip to content

Commit

Permalink
Work around an unknown ArrayBuffer bug in iOS 14.5
Browse files Browse the repository at this point in the history
In one Tabris.js application we ran into a case where an empty
ArrayBuffer was unexpectedly detached. That caused "Receiver is
detached" type error in `slice()` method.

Since we do not know for sure why and how that ArrayBuffer was happened
to be detached we implement a workaround to prevent this exception.

This issue was not reproducible in any lower version of iOS.

Change-Id: Id4216fdde4aa000ab3a4b8d996a588c0632d5297
  • Loading branch information
karolszafranski authored and tbuschto committed May 5, 2021
1 parent 8dd6cc7 commit 0c1c99b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tabris/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export function isReadable(value) {
*/
export function read(value) {
if (value instanceof ArrayBuffer) {
return value.slice(0);
return value.byteLength === 0 ? new ArrayBuffer() : value.slice(0);
}
if (ArrayBuffer.isView(value)) {
return value.buffer.slice(0);
Expand Down

0 comments on commit 0c1c99b

Please sign in to comment.