Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gluon-status-page: migrate JS to es2015-standard #2959

Closed
wants to merge 1 commit into from

Conversation

Rotzbua
Copy link
Contributor

@Rotzbua Rotzbua commented Aug 30, 2023

Change

  • Migrate JS to es2015-standard
  • Fix warning by Chrome:
    Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently

Reference

Mentioned in #2953

Fix warning by Chrome:
Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
try {
location = JSON.parse(document.body.getAttribute('data-node-location'));
} catch (e) {
console.error(e);
Copy link
Member

Choose a reason for hiding this comment

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

There is nothing wrong with a node not providing a location, this should not be logged.

We are slightly abusing the try/catch here though, something like the following would be nicer (untested):

const location_attr = document.body.getAttribute('data-node-location');
let location;
if (location_attr)
	location = JSON.parse(location_attr);

try {
lastImage = ctx.getImageData(0, 0, w, h);
} catch (e) {}
} catch (e) {
console.error(e);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure whether this should be logged. Unfortunately, I don't remember why I added the try/catch here...

MDN describes two possible exceptions: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData#exceptions

I don't think we can hit the SecurityError, so maybe this was just an ugly way to catch w or h being zero?

@blocktrron
Copy link
Member

@Rotzbua Do you still have plans for addressing the suggestions?

@rotanid
Copy link
Member

rotanid commented Dec 3, 2023

closing due to lack of reaction

@rotanid rotanid closed this Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants