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
Use image metadata to lay out images before the complete image data is available #7047
Comments
This is equivalent to Gecko's SIZE_AVAILABLE notification for imagelib. |
Note that Seth has told me that this reading of image metadata (and dealing with embedded JPEG screenshots) is a prime target for Rust in Geckoness. |
@jmr0 said they're interested in looking into this. |
Relevant code to look at for servo involves ImageListener::notify in components/net/image_cache_task.rs, and ImageResponse in components/net_traits/image_cache_task.rs. We'll want a way to notify consumers (presumably via another entry in ImageResponse) that the metadata was successfully retrieved. The logic in HTMLImageElement::update_image will need to become more complex, and HTMLImageElement will need a separate field for the metadata that we care about. Finally, the ImageFragmentInfo code in components/layout/fragment.rs is where we'll end up using the new metadata. |
@jdm I take it the goal is for this metadata to be immediately accessible to the layout task? I was looking at this today through the debugger and noticed the image fragment's metadata is, as an example, accessed in I'm curious as to whether modifying the image fragment's API ( Also, I noticed that ImageResponse is used in other places (like |
@jmr0 Yes, the code in You are also correct, the users in the webgl and canvas code are specifically concerned with the pixel data, so the metadata won't be enough for them. |
I think I've made some progress. At this point, HTMLImageElement and ImageFragment receive notifications that the metadata is available, and in the fragment's case it'll respond to I wasn't sure what this block of code was about -- seemed to be for testing or sending requests in sync mode. I'm currently handling it by only requesting a full image and not its metadata if we land here. I'm also wondering if this is the best way to handle this (whether to perform the image metadata scan in another task as that would involve some synchronization around PendingLoad's byte buffer or cloning). I'm not entirely sure how HTMLImageElement can use the metadata directly yet -- I'll take a look at the spec soon and probably send some more questions your way. Thanks again :) The whole commit is here: jmr0@83be712 |
Use image metadata to lay out images Fixes #7047. cc: @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9208) <!-- Reviewable:end -->
Use image metadata to lay out images Fixes #7047. cc: @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9208) <!-- Reviewable:end -->
Use image metadata to lay out images Fixes #7047. cc: @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9208) <!-- Reviewable:end -->
Use image metadata to lay out images Fixes #7047. cc: @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9208) <!-- Reviewable:end -->
The immeta library can provide metadata about an image given a buffer. We should use this to retrieve the dimensions of an image as soon as possible while the image is downloading.
The text was updated successfully, but these errors were encountered: