From 8ff29175d810fe94457e56ea3d0135f84ea712ab Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Fri, 21 Jul 2023 06:53:30 -0700 Subject: [PATCH] fix: Fix exception on Tizen due to unsupported Array method (#5429) Tizen 3 does not support Array.flat(). This fixes a runtime exception on Tizen 3 by replacing flat() with concat() and the spread operator. This also bans the use of flat(). flat() was originally introduced in PR #5422 --- build/conformance.textproto | 8 +++++++- lib/cea/mp4_cea_parser.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build/conformance.textproto b/build/conformance.textproto index a2ffb71ef2..4da03bcc5b 100644 --- a/build/conformance.textproto +++ b/build/conformance.textproto @@ -358,7 +358,7 @@ requirement: { } requirement: { - type: BANNED_PROPERTY + type: BANNED_PROPERTY_CALL value: "String.prototype.replaceAll" error_message: "Using \"String.replaceAll\" is not allowed; " @@ -377,3 +377,9 @@ requirement: { whitelist_regexp: "test/" } +requirement: { + type: BANNED_PROPERTY_CALL + value: "Array.prototype.flat" + error_message: + "Using \"Array.flat\" is not allowed because is not supported on Tizen 3." +} diff --git a/lib/cea/mp4_cea_parser.js b/lib/cea/mp4_cea_parser.js index 69a8936f0b..d89dcd5472 100644 --- a/lib/cea/mp4_cea_parser.js +++ b/lib/cea/mp4_cea_parser.js @@ -270,7 +270,7 @@ shaka.cea.Mp4CeaParser = class { // Combine all sample data. This assumes that the samples described across // multiple trun boxes are still continuous in the mdat box. const sampleDatas = parsedTRUNs.map((t) => t.sampleData); - const sampleData = sampleDatas.flat(); + const sampleData = [].concat(...sampleDatas); if (sampleData.length) { sampleSize = sampleData[0].sampleSize || defaultSampleSize;