Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
canvasSize
// 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({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get a comment here explaining why we're doing this? Thanks!

max: Browser.isMobile() ? 8192 : null,
usePromise: true,
useWorker: false,
})
.then(() => ({
onSuccess: (width, height) => {
Onyx.merge(ONYXKEYS.MAX_CANVAS_AREA, width * height);
},
}));
}

/**
Expand Down