You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! During developing software rendering I've decided to switch making render itself in separated thread and attempted to run example from examples/winit_multithread.rs, but got a problem that program is "stuck" at let size = window.inner_size();:
starting thread...
making surface...
waiting for render...
In docs for inner_size is see that
Platform-specific
iOS: Can only be called on the main thread.
But is it also applied to macOS platform?
I tried to remove fetching window size and it works (I've added a little code to see that different thread rendering works):
fnrender_thread(window:Arc<Window>,do_render: mpsc::Receiver<Arc<Mutex<Surface>>>,done: mpsc::Sender<()>,){letmut c:u32 = 0u32;loop{println!("waiting for render...");letOk(surface) = do_render.recv()else{println!("main thread destroyed");break;};// Perform the rendering.letmut surface = surface.lock().unwrap();let(Some(width),Some(height)) = (NonZeroU32::new(1024),NonZeroU32::new(1024))else{todo!()};
surface.resize(width, height).unwrap();letmut buffer = surface.buffer_mut().unwrap();for y in0..height.get(){for x in0..width.get(){let red = (x + c) % 255;let green = (y + c) % 255;let blue = (x * y + c) % 255;let index = y asusize* width.get()asusize + x asusize;
buffer[index] = blue | (green << 8) | (red << 16);}}println!("presenting...");
buffer.present().unwrap();// We're done, tell the main thread to keep going.
done.send(()).ok();
c += 1;}}
The text was updated successfully, but these errors were encountered:
No, it can be called from all threads on both platforms (the docs are a bit outdated on iOS), but it willblock on both platforms too, waiting on the main thread to fetch the surface size.
My recommendation would be to communicate surface size changes through a channel or a mutex or something.
This issue seems to match what we wanted to achieve with #237, and generally rethinking when to forward window resizes into softbuffer (or not, to achieve hardware scaling).
Technical details & libs versions:
Libs:
Machine:
MacBook Pro with M3
macOS:
Sonoma 14.6.1
Hi! During developing software rendering I've decided to switch making render itself in separated thread and attempted to run example from
examples/winit_multithread.rs
, but got a problem that program is "stuck" atlet size = window.inner_size();
:In docs for
inner_size
is see thatBut is it also applied to
macOS
platform?I tried to remove fetching window size and it works (I've added a little code to see that different thread rendering works):
The text was updated successfully, but these errors were encountered: