| CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
libservo: Allow embedders to drive frame updates via RefreshDriver trait
#39072
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
libservo: Allow embedders to drive frame updates via RefreshDriver trait
#39072
Conversation
|
I would like that the API we use for vsync platforms to be the implementation of a generalized interface that we also use for the fallback timer. For inspiration I think we can can follow the API that we use for clipboard. For instance, when you do not install your own custom |
@mrobinson Thanks for your suggession, but I don't understand clearly. In fact, the newly-added Besides, this PR's current change try to add a general frame tick observer and notification mechanism. However, this might be slightly beyond the scope of this PR. If a type similar to |
316c619 to
8e369ca
Compare
Could you elaborate here to make sure we are on the same page? As far as I can see there currently is a I'm not fully up to date, so maybe I'm missing something, but for me it would make sense for the embedder to be able to install a custom refresh driver, which is then also responsible for calling |
There is a default Currently the |
I think there is no other usecases for now. |
Yes, the current |
|
In my humble opinion, if |
@mrobinson @jschwe Do you think it's would be better to move out these animations logic from |
8e369ca to
69eb133
Compare
Sorry for the late reply. Yes, perhaps the animation logic should move out or we should create a |
Thanks for your reply. I prefer the first idea, but as @jschwe mentioned, there doesn't seem to be a particular reason to introduce a general frame tick notification mechanism at this point. Therefore, I will update this PR based on the |
|
Apologies for taking so long to get to this. I have more time now for API-related work. @coding-joedow You are totally correct that this change is very close to what I was thinking. I have a few minor changes to suggest around the design (in order to make the API surface a bit simpler) and naming, but I would love to tackle those this week. BTW, with this change and a few other minor ones, I was able to enable flinging for on desktop with |
Nice, this sounds very promising. I'm a bit busy at the moment and can't handle this PR right now. Sorry, and feel free to implement your ideas based on this patch, or create a new PR. |
69eb133 to
ee0fcf6
Compare
RefreshDriver trait
|
I've pushed my modifications to this branch which slightly reworks the original design. In addition, it integrates the old cc @jschwe |
|
fwiw, I tested that patch on a Pinephone Pro running Mobian, and that works very well! |
| const FRAME_DURATION: Duration = Duration::from_millis(1000 / 120); | ||
| self.queue_timer( | ||
| FRAME_DURATION, | ||
| Box::new(move || { |
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.
Seems like we can pass new_start_frame_callback directly as the timer's callback if it had a + 'static bound. Any reason we can't or don't want to do it?
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.
If I pass impl Fn() + Send + 'static I get this error:
`the size for values of type (dyn std::ops::Fn() + std::marker::Send + 'static) cannot be known at compilation time
the trait std::marker::Sized is not implemented for (dyn std::ops::Fn() + std::marker::Send + 'static) (rustc E0277)
If I pass impl Fn() + Send + 'static I get this error:
the trait embedder_traits::RefreshDriver is not dyn compatible
only type refresh_driver::TimerRefreshDriver implements embedder_traits::RefreshDriver; consider using it directly instead. (rustc E0038)
It seems we need to pass a Box.
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.
@mrobinson not sure if you've seen this comment?
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.
Sorry. I had the comment written, but it was still "Pending" in GitHub.
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.
Hmm...not sure if expressed my intention clearly in the original comment.
I mean the type for new_start_frame_callback can be Box<dyn Fn() + Send + 'static> here as well as in the trait definition of RefreshDriver and other places. That should allow passing new_start_frame_callback directly to queue_timer as it also expects a Box<dyn Fn() + Send + 'static>.
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.
Oh, I understand now. I've gone ahead and done this now.
ee0fcf6 to
6915372
Compare
|
@mukilan I've think I've addressed your review comments. PTAL. |
6915372 to
30a4bd4
Compare
30a4bd4 to
bda1131
Compare
|
🔨 Triggering try run (#18649147210) for OpenHarmony |
Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
bda1131 to
b82fda5
Compare
| } | ||
|
|
||
| pub fn on_vsync(&mut self) -> Option<FlingAction> { | ||
| pub fn notify_new_frame_start(&mut self) -> Option<FlingAction> { |
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.
Caused the problem of slippage failure.
Currently, the
RefreshDrivercreates a timer thread by default to limit the frame rate of animations to within 120fps. However, some platforms have already integratedVSYNCand even supportLTPO, making the refresh rate of the currentRefreshDrivermismatched with the display refresh rate of the platform. The main idea of this PR is to introduce theBeginFrameSourceandBeginFrameSourceObservertypes, allowingVSYNCto be integrated into the RefreshDriver.Testing: It's hard to test rendering rate but some manual tests show that it takes effect on OHOS platform, and other behavior is covered by existing WPT tests.