-
Notifications
You must be signed in to change notification settings - Fork 26
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
Ignore decode error of animation frames #1088
Conversation
This PR has been deployed to the preview environment. You can explore it using the preview URL. Warning Please note that deployments in the preview environment are temporary and will be automatically cleaned up after a certain period. Make sure to explore it before it is removed. For any questions, contact the Go+ Builder team. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.
@@ -59,7 +59,10 @@ const preloadFrames = async (costumeFiles: File[]) => { | |||
...urls.map(async (url) => { | |||
const img = new Image() | |||
img.src = url | |||
await img.decode() | |||
await img.decode().catch((e) => { | |||
// Sometimes `decode` fails, while the image is still able to be displayed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 decode
操作是起到预解码的作用吗?如果预解码失败了,渲染时浏览器会再以不同的方式尝试解码?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的
decode
操作是起到预解码的作用吗?
是的
如果预解码失败了,渲染时浏览器会再以不同的方式尝试解码?
如果是格式导致的解码失败,没理由渲染的时候跟 decode 的时候解码逻辑不同..
我猜测是图片本身过大,导致对应的 bitmap 内存占用大,浏览器内存管理的相关策略 reject 了 decode,只是以 EncodingError
的名义抛出来了。spec 里有提到
User agents should ensure that the decoded media data stays readily available until at least the end of the next successful update the rendering step in the event loop. This is an important part of the API contract, and should not be broken if at all possible. (Typically, this would only be violated in low-memory situations that require evicting decoded image data, or when the image is too large to keep in decoded form for this period of time.)
不过还只是猜测
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我猜测是图片本身过大,导致对应的 bitmap 内存占用大
这几张图片都是大概 5000x6000 大小的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
明白了
image.decode()
can sometimes fail even when the image can be displayed correctly, resulting in the error:Files that may trigger this issue can be found here: decode_error_images.zip.
This problem may be linked to large image sizes. For further discussion, see: vuetifyjs/vuetify#5418 (comment). However, this seems contradictory since
image.decode()
is intended to preload large images, as noted here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode#usage_notes.We will need to investigate this further.