-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Implement HTMLImageElement decode #31269
Implement HTMLImageElement decode #31269
Conversation
🔨 Triggering try run (#8093180833) for Linux WPT layout-2020 |
Test results for linux-wpt-layout-2020 from try job (#8093180833): Flaky unexpected result (16)
Stable unexpected results that are known to be intermittent (18)
Stable unexpected results (7)
|
|
🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync. |
@Taym95 Do you mind taking a look at the failing tests? It seems that this change introduces some failure and timeouts. |
I pushed another commit after last |
🔨 Triggering try run (#8111488522) for Linux WPT |
Test results for linux-wpt-layout-2020 from try job (#8111488522): Flaky unexpected result (18)
Stable unexpected results that are known to be intermittent (15)
Stable unexpected results (4)
|
|
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.
Great start! Some pointers for the next step. Note that this is actually simpler than what I wrote in the initial issue...
@Taym95 Any updates on this one? Is there some way that I can help you get this ready for review again? |
Sorry, @mrobinson, I was busy in previous weeks. I will continue working on this this week. |
c1df1b6
to
d3f2d8b
Compare
@mrobinson Can you run |
🔨 Triggering try run (#9348660545) for Linux WPT |
Test results for linux-wpt-layout-2013 from try job (#9348660545): Flaky unexpected result (7)
Stable unexpected results that are known to be intermittent (10)
Stable unexpected results (4)
|
Test results for linux-wpt-layout-2020 from try job (#9348660545): Flaky unexpected result (14)
Stable unexpected results that are known to be intermittent (10)
Stable unexpected results (4)
|
…ilable Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
Thanks, I addressed these remarks |
Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
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.
Ok, one last thing I'd like to check.
for promise in self.image_decode_promises.borrow().iter() { | ||
promise.resolve_native(&()); | ||
} | ||
self.image_decode_promises.borrow_mut().clear(); |
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.
would it not be better to just do a drain(...)
above?
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.
We can use drain(..)
from the doc I saw:
/// // A full range clears the vector, like `clear()` does
/// v.drain(..);
/// assert_eq!(v, &[]);
@@ -1345,6 +1397,9 @@ pub enum ImageElementMicrotask { | |||
elem: DomRoot<HTMLImageElement>, | |||
generation: u32, | |||
}, | |||
DecodeTask { | |||
elem: DomRoot<HTMLImageElement>, |
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.
One last thing I thought about: there is currently a race condition between when the microtask runs, and the "in parallel" stuff described at 2.2. For example if the request becomes broken, we will reject all promises, including the one for which the micro task hasn't run yet.
I'm not sure this is actually a problem, but we may as well be consitent with the spec and:
- In
Decode
, not store the promise onpending_
, but rather store it here in the task. - change
react_to_decode_image_sync_steps
as described above.
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.
I moved storing promise in task and tests are okey
if !document.is_fully_active() || | ||
matches!(self.current_request.borrow().state, State::Broken) | ||
{ | ||
self.reject_image_decode_promises(); |
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.
here, as per the comment below, let's only reject the promise associated with the task, and remove the resolve logic below. Instead, if the promise is not rejected, we should store it on pending_
, and resolve/reject it later as the request state changes.
I'm going to run the wpt tests before this change, and after, just to see if this makes a difference.
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.
I removed the resolve logic but it broke lot of tests.
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.
Ok, I will just run the tests once to see, but probably we should then keep it. I guess its a kind of race condition in the spec, between the microtask and the parallel steps.
🔨 Triggering try run (#9464494120) for Linux WPT |
Test results for linux-wpt-layout-2020 from try job (#9464494120): Flaky unexpected result (10)
Stable unexpected results that are known to be intermittent (15)
|
✨ Try run (#9464494120) succeeded. |
Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
🔨 Triggering try run (#9470224661) for Linux WPT |
Test results for linux-wpt-layout-2020 from try job (#9470224661): Flaky unexpected result (14)
Stable unexpected results that are known to be intermittent (9)
Stable unexpected results (3)
|
|
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.
Ok, one comment and lets undo the last commit please.
@@ -1173,7 +1173,11 @@ impl HTMLImageElement { | |||
} | |||
|
|||
// Step 2 for <https://html.spec.whatwg.org/multipage/#dom-img-decode> | |||
fn react_to_decode_image_sync_steps(&self) { | |||
fn react_to_decode_image_sync_steps(&self, promise: Rc<Promise>) { | |||
self.image_decode_promises |
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.
What I meant is that we should only resolve or reject this particular promise here, and if neither happens, at the end of the function store it into this.
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.
done
Note also there is a discussion ongoing about the potential race condition I mentioned, at whatwg/html#4217. |
This reverts commit eee6096.
Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync. |
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.
LGTM
&document.global(), | ||
DOMErrorName::EncodingError, | ||
)); | ||
} else if matches!( |
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.
Here I would add a comment that this does not follow the spec, but it is discussed at whatwg/html#4217
…ailable Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
🛠 These changes could not be applied onto the latest upstream WPT. Servo's copy of the Web Platform Tests may be out of sync. |
Thank you, great work! @Taym95 |
./mach build -d
does not report any errors./mach test-tidy
does not report any errors