Skip to content
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

Presentation time is reported to wrong surface commits #4451

Closed
YaLTeR opened this issue Aug 15, 2019 · 3 comments · Fixed by #4465
Closed

Presentation time is reported to wrong surface commits #4451

YaLTeR opened this issue Aug 15, 2019 · 3 comments · Fixed by #4465
Labels
bug Not working as intended

Comments

@YaLTeR
Copy link
Contributor

YaLTeR commented Aug 15, 2019

  • Sway Version: 1.1-rc1-99-g724926ea (Aug 7 2019, branch 'makepkg')

As far as I can understand the logic between sway and wlroots, presentation-time is delivered to the last surface commit at the time of the presentation. However, that's not entirely correct: it should be delivered to the surface commit that was displayed in the presentation, so in sway that would be something along the last surface commit at the time of output_render.

In particular, the current behavior results in timestamps of up to one frame off for surfaces which render their contents on the frame callback. To see why, look at this diagram (that I recorded from rootston, but as far as I can tell the relevant parts work the same way in sway):

timestamps

Red lines are presentation timestamps (yes, they are not aligned with the other lines, I noted that in swaywm/wlroots#655 (comment), but this isn't relevant here), the top half of the graph depicts the time from the page flip to output_render start and end (green and blue dots) when the surface contents are sampled, with the next frame callback send right afterwards. At the bottom half of the graph you can see the life-cycle of surface contents, being rendered and committed on frame, represented by the triangle (shortly after the blue dot because frame is currently sent right after output_render), then sampled during the next output_render (represented by the circle) and finally presented on screen during the presentation after that.

In this case, the last commit before a presentation will be presented only on the next presentation, so effectively the reported timestamp is one frame earlier than it should be.

@emersion
Copy link
Member

However, that's not entirely correct: it should be delivered to the surface commit that was displayed in the presentation, so in sway that would be something along the last surface commit at the time of output_render.

I don't think it works that way. We don't have precise timings and the sequence number at this point. We only have those in the pageflip handler.

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Aug 15, 2019

What I'm saying is that presentation should be sent at the same time it's sent now, but to a different object. There should probably be two presentation objects for each surface: one for the commit sampled during the last output_render (this one will receive the presentation event), and one for the latest commit (this one will either receive presentation event later, after output_render and a subsequent presentation, or it will receive the discarded event if something else is committed before output_render).

@emersion
Copy link
Member

In this case, the last commit before a presentation will be presented only on the next presentation, so effectively the reported timestamp is one frame earlier than it should be.

Oh, I see what you mean. Indeed, that seems wrong. We should "remember" the presentation objects that were around at compositing time, and only send a presented event to them (not to the new ones created in-between).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Development

Successfully merging a pull request may close this issue.

2 participants