From 0c1c99b01753e05cfeb615787db6bf11ceb0488d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20Szafra=C5=84ski?= Date: Tue, 4 May 2021 16:40:58 +0200 Subject: [PATCH] Work around an unknown ArrayBuffer bug in iOS 14.5 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 --- src/tabris/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tabris/util.js b/src/tabris/util.js index b03e4f42..d0fbba25 100644 --- a/src/tabris/util.js +++ b/src/tabris/util.js @@ -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);