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

Amend PNG image fallback code #55

Merged
merged 1 commit into from Feb 28, 2020
Merged

Amend PNG image fallback code #55

merged 1 commit into from Feb 28, 2020

Conversation

tidoust
Copy link
Member

@tidoust tidoust commented Feb 28, 2020

The "onerror" handler for the SVG image that aims at replacing the image with a PNG version created an infinite loop in the (unlikely, granted) event when there are transient network troubles (due to the server or the connection) after the spec has been retrieved but before the SVG image has been retrieved.

In such a scenario, the fetch on the image would trigger the handler, which would change the image source to the URL of the PNG image, which would trigger another fetch, which would trigger the handler, which would change the source to the same value but that's enough to trigger another fetch, etc.

This fix only changes the source URL once.

Actually, the scenario that more directly affects me is that of a crawling tool that wants to render the spec in a headless browser while avoiding unnecessary network requests (typically those on images): the headless browser would keep on issuing network requests, and fail to report that the spec seems "done loading".

The same problem exists on the Magnetometer spec. If that solution works here, I'll create the same pull request there...


Preview | Diff

The "onerror" handler for the SVG image that aims at replacing the image with a
PNG version created an infinite loop in the (unlikely, granted) event when the
client lost her network connection after having loaded the spec but before
having loaded the SVG image.

In such a scenario, the fetch on the image would trigger the handler, which
would change the image source to the URL of the PNG image, which would trigger
another fetch, which would trigger the handler, which would change the source
to the same value but that's enough to trigger another fetch, etc.

This fix only changes the source URL once.
@tidoust tidoust requested a review from anssiko February 28, 2020 13:03
tidoust added a commit to tidoust/magnetometer that referenced this pull request Feb 28, 2020
The "onerror" handler for the SVG image that aims at replacing the image with a
PNG version created an infinite loop in the (unlikely, granted) event when the
client lost her network connection after having loaded the spec but before
having loaded the SVG image. See discussion in:
w3c/accelerometer#55

This fix only changes the source URL once.
@anssiko
Copy link
Member

anssiko commented Feb 28, 2020

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants