Skip to content

Commit

Permalink
Try willReadFrequently
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Sep 9, 2023
1 parent fea1d77 commit 696a463
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/account-info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ function AccountInfo({
try {
// Get color from four corners of image
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d', {
willReadFrequently: true,
});
canvas.width = e.target.width;
canvas.height = e.target.height;
ctx.drawImage(e.target, 0, 0);
Expand Down
4 changes: 3 additions & 1 deletion src/components/avatar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const alphaCache = {};
const canvas = window.OffscreenCanvas
? new OffscreenCanvas(1, 1)
: document.createElement('canvas');
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d', {
willReadFrequently: true,
});

function Avatar({ url, size, alt = '', squircle, ...props }) {
size = SIZES[size] || size || SIZES.m;
Expand Down

0 comments on commit 696a463

Please sign in to comment.