w3c / accelerometer

Accelerometer
https://www.w3.org/TR/accelerometer/
Other
18 stars 25 forks source link

Amend PNG image fallback code #55

Closed tidoust closed 4 years ago

tidoust commented 4 years ago

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

anssiko commented 4 years ago

👍