Use willReadFrequently to potentially improve skin parsing perf

This commit is contained in:
Jordan Eldredge 2025-06-19 12:33:07 -07:00
parent 415a06f80f
commit 6432753d20
3 changed files with 10 additions and 4 deletions

View file

@ -1,6 +1,12 @@
## Upcoming [UNRELEASED] (`webamp@next`)
_No changes yet._
### Bug Fixes
- Fixed "Generate HTML Playlist" feature, which was accidentally broken in 2.0.0.
### Improvements
- Improve skin parsing performance and avoid Chrome console warning by adding `willReadFrequently` to canvas contexts.
## 2.0.1 [CURRENT]

View file

@ -99,7 +99,7 @@ async function genGenTextSprites(zip) {
}
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
const context = canvas.getContext("2d", { willReadFrequently: true });
canvas.width = img.width;
canvas.height = img.height;
context.drawImage(img, 0, 0);

View file

@ -81,7 +81,7 @@ export function getSpriteUrisFromImg(
sprites: Sprite[]
): { [spriteName: string]: string } {
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
const context = canvas.getContext("2d", { willReadFrequently: true });
if (context == null) {
throw new Error("Failed to get canvas context");
}
@ -194,7 +194,7 @@ export async function getGenExColors(
}
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
const context = canvas.getContext("2d", { willReadFrequently: true });
if (context == null) {
return null;
}