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
script: Start replacing time
with std::time
and chrono
#30639
Conversation
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.
Nicely done! I have a few comments below, but generally speaking this looks great.
components/script/script_runtime.rs
Outdated
let dur = SystemTime::now() | ||
.duration_since(start.get().unwrap()) | ||
.unwrap(); |
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 think we should try to not panic here, so please provide defaults if we cannot unwrap successfully.
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.
Changed the last unwrap
to unwrap_or_default
, for lack of a smarter solution.
components/script/script_runtime.rs
Outdated
let dur = SystemTime::now() | ||
.duration_since(start.get().unwrap()) | ||
.unwrap(); |
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.
The same comment here.
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.
components/script/script_thread.rs
Outdated
@@ -258,7 +261,7 @@ impl InProgressLoad { | |||
is_visible: true, | |||
url: url, | |||
origin: origin, | |||
navigation_start: (current_time.sec * 1000 + current_time.nsec as i64 / 1000000) as u64, | |||
navigation_start: navigation_start, |
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.
navigation_start: navigation_start, | |
navigation_start, |
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 contemplated doing this but it seems this would be better dealt with in a big fmt
change.
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 could enforce it with use_field_init_shorthand.
I'm nearly done; only have EDIT: Immediately after commenting I got an answer on Zulip, which allowed me to get a solution that compiles; however, I will put in a bit more work to potentially get a more robust solution that doesn't involve EDIT: Seems like the |
8a2d446
to
3da3176
Compare
3da3176
to
59979aa
Compare
59979aa
to
669a209
Compare
Looks like this is a flake in the float tests...frustrating and they should probably be switched away from a fuzzing approach to a traditional test framework. I'm resending this to the MQ. |
@mrobinson Thanks for the review! Please consider resolving the above conversations as I'm interested in your opinion on these. |
It seems that some animation and performance tests are failing, likely because the new code is returning different results that the old code. One way to debug this is to compare the two times (via the old APIs and the new ones) via print statements to see where they are different. Failures: |
669a209
to
f227071
Compare
🔨 Triggering try run (#6747135167) with platforms=linux,macos,windows and layout=all |
Test results for linux-wpt-layout-2013 from try job (#6747135167): Flaky unexpected result (20)
Stable unexpected results that are known to be intermittent (21)
Stable unexpected results (7)
|
Test results for linux-wpt-layout-2020 from try job (#6747135167): Flaky unexpected result (17)
Stable unexpected results that are known to be intermittent (14)
Stable unexpected results (4)
|
Some of these test failures might be linked to the fact that |
Where possible use https://doc.rust-lang.org/std/time/struct.Instant.html |
The new set of results looks a lot better! I think this is getting quite close. I would also rebase this as at least one of these failures should be fixed in the latest from the main branch. |
I'm reworking the changes and there is something I find strange. The servo/components/script/dom/globalscope.rs Line 207 in f227071
The first time they're used it's to put in a timestamp: servo/components/script/dom/globalscope.rs Line 2272 in f227071
whereas the second time it's to put in the elapsed time since the timestamp: servo/components/script/dom/globalscope.rs Line 2284 in f227071
Ideally |
f227071
to
d4ed3e0
Compare
Test results for linux-wpt-layout-2020 from try job (#7531522298): Flaky unexpected result (10)
Stable unexpected results that are known to be intermittent (14)
Stable unexpected results (3)
|
|
Looks like there is at least one more issue to address. |
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
….rs` Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Use Instant a bit more and stop using chrono. Do not transition `navigation_start_precise` to Instant yet as we need to coordinate this across all crates.
e0742c1
to
6b95401
Compare
🔨 Triggering try run (#7540553241) with platforms=linux and layout=undefined |
Test results for linux-wpt-layout-2020 from try job (#7540553241): Flaky unexpected result (17)
Stable unexpected results that are known to be intermittent (12)
|
✨ Try run (#7540553241) succeeded. |
time
with std::time
in components/script
time
with std::time
and chrono
I had to make some changes to get this working namely, fixing some precision issues in the animation timeline as well as not making the changes for |
This change is intended to be reviewed commit-by-commit.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorstime
(precise_time_ns
) withstd::time
,chrono
, or the newtime
crate #30150