Skip to content

Deal with scale factor changes/configure races on Wayland #2921

@kchibisov

Description

@kchibisov

When doing rendering on a different thread than the event loop is located and not doing any sort of synchronization with the way rendering is being done winit could change the scale factor of the buffer the surface will submit, leading to the protocol errors due to a fact that the buffer is not
dividable by the scale factor of the buffer.

The same situation happens with the configure events which we should generally manually ack, but we just ack unconditionally, so the client could theoretically render with the wrong configure information.

To solve this one solution would be to let the users confirm the scaling/sizes they are trying to use before they do the actual rendering with the serial of the configure (could be encapsulated inside the Resized event), etc. The same should apply to scale they are using.

We've developed a concept of Window::pre_present_notify in #2896 , but it doesn't really help here, because it happens right before the presentation.

So what we'll need is Window::pre_rendering_notify(Resized, Scale) (maybe something else?), so the clients could manually provide the sizes they actually end up using and once they do so, winit will update its inner logic and set the scale factors clients have picked.

  • I have no clue how it'll all work with the other backends, they likely don't need such a messy handling.
  • I don't think all of that could be done automatically.
  • Even if we have a special event users must draw on it's all weird with the Window being on the different thread, because realistically you don't have to wait for the event.
  • Having to wait is a real issue if you have like 20 windows each using its own thread, because you don't want to wait 20 threads to finish their rendering, it's just a nonsense thing.

Maybe we should have an opt-in behavior for all of that, like when building window, because realistically only multithreaded clients do want this sort of sync, but it'll be a blood mess to maintain internally, since sometimes you maintain configure queue, sometimes don't, sometimes you apply the scaling, sometimes don't, it'll be just all over the place?

--

Alternative name to all of that could be Window::ack_size_and_scale(Resized, scale). Also, it's not clear in which form we should accept size and scale in such function, I'd assume that we'd need serials, and not real sizes.

Metadata

Metadata

Assignees

Labels

DS - waylandAffects the Wayland backend, or generally free Unix platforms

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions