Skip to content

Commit

Permalink
Merge pull request #29103 from ZhenjaHorbach/Chrome-crashes-on-openin…
Browse files Browse the repository at this point in the history
…g-password-protected-PDF

Android chrome crashes on opening password protected PDF
  • Loading branch information
youssef-lr authored Oct 11, 2023
2 parents 723d5a0 + 1793df2 commit 0bc4876
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/libs/actions/CanvasSize.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
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);
},
});
// 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,
usePromise: true,
useWorker: false,
})
.then(() => ({
onSuccess: (width, height) => {
Onyx.merge(ONYXKEYS.MAX_CANVAS_AREA, width * height);
},
}));
}

/**
Expand Down

0 comments on commit 0bc4876

Please sign in to comment.