Try again when wl_display.flush() returns EAGAIN
This was causing us to exist when we probably shouldn't have been. I think the main issue was all the syncNextCommit calls for the bar. These changes have seeminglly fixed my crash
This commit is contained in:
parent
f76fa239ee
commit
f10eecffc4
2 changed files with 10 additions and 5 deletions
|
|
@ -319,8 +319,6 @@ pub fn draw(bar: *Bar) !void {
|
||||||
// Attach the buffer to the surface
|
// Attach the buffer to the surface
|
||||||
const surfaces = bar.surfaces orelse return error.NoSurfaces;
|
const surfaces = bar.surfaces orelse return error.NoSurfaces;
|
||||||
const wl_surface = surfaces.wl_surface;
|
const wl_surface = surfaces.wl_surface;
|
||||||
// sync_next_commit ensures frame-perfect application
|
|
||||||
surfaces.river_shell_surface.syncNextCommit();
|
|
||||||
wl_surface.setBufferScale(scale);
|
wl_surface.setBufferScale(scale);
|
||||||
wl_surface.attach(buffer.wl_buffer, 0, 0);
|
wl_surface.attach(buffer.wl_buffer, 0, 0);
|
||||||
wl_surface.damageBuffer(0, 0, render_width, render_height);
|
wl_surface.damageBuffer(0, 0, render_width, render_height);
|
||||||
|
|
|
||||||
13
src/main.zig
13
src/main.zig
|
|
@ -124,9 +124,16 @@ fn run(wl_display: *wl.Display, context: *Context) !void {
|
||||||
};
|
};
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const errno = wl_display.flush();
|
const flush_errno = wl_display.flush();
|
||||||
if (errno != .SUCCESS) {
|
if (flush_errno == .AGAIN) {
|
||||||
fatal("wl_display flush failed: E{s}", .{@tagName(errno)});
|
// Send buffer is full; ask poll to wake us when the socket is writable
|
||||||
|
// again so we can retry the flush at the top of the next iteration.
|
||||||
|
pollfds[poll_wayland].events = posix.POLL.IN | posix.POLL.OUT;
|
||||||
|
} else if (flush_errno != .SUCCESS) {
|
||||||
|
fatal("wl_display flush failed: E{s}", .{@tagName(flush_errno)});
|
||||||
|
} else {
|
||||||
|
// Flush succeeded; stop polling for writability.
|
||||||
|
pollfds[poll_wayland].events = posix.POLL.IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the number of milliseconds to the top of the next second
|
// Get the number of milliseconds to the top of the next second
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue