From 3aafc7c9726b2236e08bece42d386fa1496c0c8b Mon Sep 17 00:00:00 2001 From: Yauheni Date: Mon, 9 Oct 2023 18:29:36 +0200 Subject: [PATCH 1/5] Fix app crash on opening password protected PDF --- src/libs/actions/CanvasSize.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/CanvasSize.js b/src/libs/actions/CanvasSize.js index ed83562a3e43..5f985855f2ae 100644 --- a/src/libs/actions/CanvasSize.js +++ b/src/libs/actions/CanvasSize.js @@ -1,16 +1,23 @@ import Onyx from 'react-native-onyx'; import canvasSize from 'canvas-size'; import ONYXKEYS from '../../ONYXKEYS'; +import * as Browser from '../Browser'; /** * Calculate the max area of canvas on this specific platform and save it in onyx */ function retrieveMaxCanvasArea() { - canvasSize.maxArea({ - onSuccess: (width, height) => { - Onyx.merge(ONYXKEYS.MAX_CANVAS_AREA, width * height); - }, - }); + canvasSize + .maxArea({ + max: Browser.isMobile() ? 8192 : null, + usePromise: true, + useWorker: false, + }) + .then(() => ({ + onSuccess: (width, height) => { + Onyx.merge(ONYXKEYS.MAX_CANVAS_AREA, width * height); + }, + })); } /** From ba6bb2c49d4862007fdae7740e6abe3858bb2320 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Tue, 10 Oct 2023 14:49:53 +0200 Subject: [PATCH 2/5] Update comment for retrieveMaxCanvasArea --- src/libs/actions/CanvasSize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/CanvasSize.js b/src/libs/actions/CanvasSize.js index 5f985855f2ae..10809fdb14d5 100644 --- a/src/libs/actions/CanvasSize.js +++ b/src/libs/actions/CanvasSize.js @@ -4,7 +4,7 @@ import ONYXKEYS from '../../ONYXKEYS'; import * as Browser from '../Browser'; /** - * Calculate the max area of canvas on this specific platform and save it in onyx + * Calculate the max area of canvas on this specific platform and save it in onyx. The maximum value was limited because on mobile devices there is a crash related to the size of the area */ function retrieveMaxCanvasArea() { canvasSize From 83c0093ea014120aea6690520350eb1c0b5bde0f Mon Sep 17 00:00:00 2001 From: Yauheni Date: Tue, 10 Oct 2023 16:19:57 +0200 Subject: [PATCH 3/5] Update comment for retrieveMaxCanvasArea x2 --- src/libs/actions/CanvasSize.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/CanvasSize.js b/src/libs/actions/CanvasSize.js index 10809fdb14d5..2e8557070cf4 100644 --- a/src/libs/actions/CanvasSize.js +++ b/src/libs/actions/CanvasSize.js @@ -4,7 +4,9 @@ import ONYXKEYS from '../../ONYXKEYS'; import * as Browser from '../Browser'; /** - * Calculate the max area of canvas on this specific platform and save it in onyx. The maximum value was limited because on mobile devices there is a crash related to the size of the area + * Calculate the max area of canvas on this specific platform and save it in onyx. + We're limiting the maximum value on mobile web to prevent a crash related to rendering large canvas elements. + More information at: https://github.com/jhildenbiddle/canvas-size/issues/13 */ function retrieveMaxCanvasArea() { canvasSize From 1e2b7f4d0b99d69ec7a789cf49d847862d00f88f Mon Sep 17 00:00:00 2001 From: Yauheni Date: Tue, 10 Oct 2023 16:26:31 +0200 Subject: [PATCH 4/5] Update comment for retrieveMaxCanvasArea x3 --- src/libs/actions/CanvasSize.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/CanvasSize.js b/src/libs/actions/CanvasSize.js index 2e8557070cf4..fddb92c81e2d 100644 --- a/src/libs/actions/CanvasSize.js +++ b/src/libs/actions/CanvasSize.js @@ -4,11 +4,11 @@ import ONYXKEYS from '../../ONYXKEYS'; import * as Browser from '../Browser'; /** - * Calculate the max area of canvas on this specific platform and save it in onyx. - We're limiting the maximum value on mobile web to prevent a crash related to rendering large canvas elements. - More information at: https://github.com/jhildenbiddle/canvas-size/issues/13 + * Calculate the max area of canvas on this specific platform and save it in onyx. */ function retrieveMaxCanvasArea() { + // We're limiting the maximum value on mobile web to prevent a crash related to rendering large canvas elements. + // More information at: https://github.com/jhildenbiddle/canvas-size/issues/13 canvasSize .maxArea({ max: Browser.isMobile() ? 8192 : null, From 1793df25cb1f38c26c745b0d3c8d3c41006eff5d Mon Sep 17 00:00:00 2001 From: Yauheni Date: Tue, 10 Oct 2023 16:28:06 +0200 Subject: [PATCH 5/5] Update comment for retrieveMaxCanvasArea x4 --- src/libs/actions/CanvasSize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/CanvasSize.js b/src/libs/actions/CanvasSize.js index fddb92c81e2d..0c4cd88fea70 100644 --- a/src/libs/actions/CanvasSize.js +++ b/src/libs/actions/CanvasSize.js @@ -4,7 +4,7 @@ import ONYXKEYS from '../../ONYXKEYS'; import * as Browser from '../Browser'; /** - * Calculate the max area of canvas on this specific platform and save it in onyx. + * Calculate the max area of canvas on this specific platform and save it in onyx */ function retrieveMaxCanvasArea() { // We're limiting the maximum value on mobile web to prevent a crash related to rendering large canvas elements.