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

Low-latency rendering with the desynchronized hint #6667

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/rust/web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ ops! { HtmlCanvasElementOps for HtmlCanvasElement
fn get_webgl2_context(&self) -> Option<WebGl2RenderingContext> {
let options = Object::new();
Reflect::set(&options, &"antialias".into(), &false.into()).unwrap();
// See: https://developer.chrome.com/blog/desynchronized
Reflect::set(&options, &"desynchronized".into(), &true.into()).unwrap();
Comment on lines +689 to +690
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the link, and I'm a bit unsure about it.

First, it does not explain directly what are drawbacks of setting this option. I guess there are some, as otherwise this would be default in every browser. We display both canvas as other HTML elements, so we may technically be affected.

Furthermore, I don't know why we do not add "preserveDrawingBuffer" option as described in https://developer.chrome.com/blog/desynchronized/#avoiding-flicker

Moreover, there is a warning in https://developer.chrome.com/blog/desynchronized/#alpha-channels that:

A translucent canvas element, one where alpha is set to true, can still be desynchronized, but it must not have any other DOM elements above it.

But we definitely have other DOM elements above our canvas, and it definitely has alpha.

I think these things should be discussed in the comment. Otherwise anyone else who will read the article may ask same questions.

let context = self.get_context_with_context_options("webgl2", &options).ok().flatten();
context.and_then(|obj| obj.dyn_into::<WebGl2RenderingContext>().ok())
}
Expand Down