Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse microtasks to await a stable state. #16861
Conversation
highfive
commented
May 14, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
May 14, 2017
|
As an update on the above, I have used this commit(as well as implemented a |
| @@ -420,6 +421,13 @@ unsafe impl JSTraceable for Box<LayoutRPC + Send + 'static> { | |||
| } | |||
| } | |||
|
|
|||
| unsafe impl JSTraceable for Box<Runnable + Send + 'static> { | |||
This comment has been minimized.
This comment has been minimized.
jdm
May 15, 2017
Member
This is not a safe construct, since it allows us to store non-GC safe values in Runnables.
| @@ -28,6 +32,13 @@ pub struct MicrotaskQueue { | |||
| #[derive(JSTraceable, HeapSizeOf)] | |||
| pub enum Microtask { | |||
| Promise(EnqueuedPromiseCallback), | |||
| AwaitStableState(Box<Runnable + Send>) | |||
This comment has been minimized.
This comment has been minimized.
jdm
May 15, 2017
Member
Instead of using Runnables for this and await_stable_state, let's have MedieElement(MediaElementMicrotask), ImageElement(ImageElementMicrotask), where the inner types are enums. We can define a MicrotaskRunnable trait that the enums implement with a handler(&self) method.
242bf4d
to
0e6bcee
100f6f1
to
98744a0
|
@jdm thanks for the suggestions, I've made an attempt using enums... Note I've had to |
|
It's better to use |
|
As for whether it's necessary, that's a good point. It's true that there's no threading involved, so a Root value should work instead. |
| } | ||
| } | ||
|
|
||
| impl HeapSizeOf for Trusted<HTMLMediaElement> { |
This comment has been minimized.
This comment has been minimized.
| @@ -626,14 +626,12 @@ impl ScriptThread { | |||
| } | |||
|
|
|||
| // https://html.spec.whatwg.org/multipage/#await-a-stable-state | |||
| pub fn await_stable_state<T: Runnable + Send + 'static>(task: T) { | |||
| pub fn await_stable_state(task: Microtask) { | |||
| //TODO use microtasks when they exist | |||
This comment has been minimized.
This comment has been minimized.
| base_url: ServoUrl | ||
| }, | ||
| PauseIfNotInDocumentTask { | ||
| elem: Trusted<HTMLMediaElement>, |
This comment has been minimized.
This comment has been minimized.
98744a0
to
3fdf6c8
|
@jdm thanks, ready for another round or review... |
3fdf6c8
to
b1c4edb
|
@bors-servo: r+ |
|
|
…r=jdm Use microtasks to await a stable state. <!-- Please describe your changes on the following line: --> @jdm @KiChjang First pass at using microtasks to await a stable state. I ran into all sorts of problems to get it to compile, I think it's mainly related to the fact that the microtasks are stored in a `Vec`, which meant the `Runnalbe.handler(self: Box<Self>)` couldn't be called while iterating over the Vec... It compiles now although I haven't run any tests. I'm assuming I'm missing something fundamental and was hoping my changes would highlight the problems I run into, and you had a better idea of how to implement this... Perhaps we shouldn't pass a `Runnable` to `await_stable_state` at all? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #15375 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16861) <!-- Reviewable:end -->
|
|
|
Oh, it does seem like networkState_during_progress.html consistently times out. Could you revert that expectation change? |
765d199
to
a8390ae
|
@jdm yep, done. Build failure seems unrelated by the way... |
|
@bors-servo: r+ |
|
|
…r=jdm Use microtasks to await a stable state. <!-- Please describe your changes on the following line: --> @jdm @KiChjang First pass at using microtasks to await a stable state. I ran into all sorts of problems to get it to compile, I think it's mainly related to the fact that the microtasks are stored in a `Vec`, which meant the `Runnalbe.handler(self: Box<Self>)` couldn't be called while iterating over the Vec... It compiles now although I haven't run any tests. I'm assuming I'm missing something fundamental and was hoping my changes would highlight the problems I run into, and you had a better idea of how to implement this... Perhaps we shouldn't pass a `Runnable` to `await_stable_state` at all? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #15375 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16861) <!-- Reviewable:end -->
|
|
|
@bors-servo: retry
|
…r=jdm Use microtasks to await a stable state. <!-- Please describe your changes on the following line: --> @jdm @KiChjang First pass at using microtasks to await a stable state. I ran into all sorts of problems to get it to compile, I think it's mainly related to the fact that the microtasks are stored in a `Vec`, which meant the `Runnalbe.handler(self: Box<Self>)` couldn't be called while iterating over the Vec... It compiles now although I haven't run any tests. I'm assuming I'm missing something fundamental and was hoping my changes would highlight the problems I run into, and you had a better idea of how to implement this... Perhaps we shouldn't pass a `Runnable` to `await_stable_state` at all? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #15375 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16861) <!-- Reviewable:end -->
|
|

gterzian commentedMay 14, 2017
•
edited by larsbergstrom
@jdm @KiChjang First pass at using microtasks to await a stable state. I ran into all sorts of problems to get it to compile, I think it's mainly related to the fact that the microtasks are stored in a
Vec, which meant theRunnalbe.handler(self: Box<Self>)couldn't be called while iterating over the Vec... It compiles now although I haven't run any tests. I'm assuming I'm missing something fundamental and was hoping my changes would highlight the problems I run into, and you had a better idea of how to implement this... Perhaps we shouldn't pass aRunnabletoawait_stable_stateat all?./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is