gl-renderer, pixman: disconnect the client on unhandled buffer type.

Introduce a helper function to disconnect the client on unhandled
buffer types, and use it in the gl and pixman renderers. The function
is modeled after linux_dmabuf_buffer_send_server_error.

Also print the egl error state in the gl renderer, in case the
unrecognized buffer error happens when querying an egl buffer.

https://gitlab.freedesktop.org/wayland/weston/issues/148
dev
Vasilis Liaskovitis 6 years ago committed by Daniel Stone
parent 807cd2e589
commit 486b463a18
  1. 35
      libweston/compositor.c
  2. 4
      libweston/compositor.h
  3. 6
      libweston/gl-renderer.c
  4. 5
      libweston/pixman-renderer.c

@ -7103,3 +7103,38 @@ weston_compositor_load_xwayland(struct weston_compositor *compositor)
return -1; return -1;
return 0; return 0;
} }
/** Resolve an internal compositor error by disconnecting the client.
*
* This function is used in cases when the wl_buffer turns out
* unusable and there is no fallback path.
*
* It is possible the fault is caused by a compositor bug, the underlying
* graphics stack bug or normal behaviour, or perhaps a client mistake.
* In any case, the options are to either composite garbage or nothing,
* or disconnect the client. This is a helper function for the latter.
*
* The error is sent as an INVALID_OBJECT error on the client's wl_display.
*
* \param buffer The weston buffer that is unusable.
* \param msg A custom error message attached to the protocol error.
*/
WL_EXPORT void
weston_buffer_send_server_error(struct weston_buffer *buffer,
const char *msg)
{
struct wl_client *client;
struct wl_resource *display_resource;
uint32_t id;
assert(buffer->resource);
id = wl_resource_get_id(buffer->resource);
client = wl_resource_get_client(buffer->resource);
display_resource = wl_client_get_object(client, 1);
assert(display_resource);
wl_resource_post_error(display_resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"server error with "
"wl_buffer@%u: %s", id, msg);
}

@ -2345,6 +2345,10 @@ weston_debug_compositor_create(struct weston_compositor *compositor);
void void
weston_debug_compositor_destroy(struct weston_compositor *compositor); weston_debug_compositor_destroy(struct weston_compositor *compositor);
void
weston_buffer_send_server_error(struct weston_buffer *buffer,
const char *msg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -2377,10 +2377,16 @@ gl_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
gl_renderer_attach_dmabuf(es, buffer, dmabuf); gl_renderer_attach_dmabuf(es, buffer, dmabuf);
else { else {
weston_log("unhandled buffer type!\n"); weston_log("unhandled buffer type!\n");
if (gr->has_bind_display) {
weston_log("eglQueryWaylandBufferWL failed\n");
gl_renderer_print_egl_error_state();
}
weston_buffer_reference(&gs->buffer_ref, NULL); weston_buffer_reference(&gs->buffer_ref, NULL);
gs->buffer_type = BUFFER_TYPE_NULL; gs->buffer_type = BUFFER_TYPE_NULL;
gs->y_inverted = 1; gs->y_inverted = 1;
es->is_opaque = false; es->is_opaque = false;
weston_buffer_send_server_error(buffer,
"disconnecting due to unhandled buffer type");
} }
} }

@ -661,8 +661,11 @@ pixman_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
es->is_opaque = true; es->is_opaque = true;
break; break;
default: default:
weston_log("Unsupported SHM buffer format\n"); weston_log("Unsupported SHM buffer format 0x%x\n",
wl_shm_buffer_get_format(shm_buffer));
weston_buffer_reference(&ps->buffer_ref, NULL); weston_buffer_reference(&ps->buffer_ref, NULL);
weston_buffer_send_server_error(buffer,
"disconnecting due to unhandled buffer type");
return; return;
break; break;
} }

Loading…
Cancel
Save