I'm using weston on an armv7 device. I'm using the weston's screenshooter module to capture screenshots on it from time to time, but what I noticed is that when a screenshot is being captured, the whole image being displayed gets frozen for over a second, which causes an ugly jitter on the screen.
I have examined the screenshot.c code in weston source and compiled it with some simple performance measurements (time now - time after), and found out that only one place in the entire code is causing this jitter: the while loop that waits for wl_display_roundtrip:
wl_list_for_each(output, &output_list, link) {
output->buffer = create_shm_buffer(output->width, output->height, &output->data);
weston_screenshooter_shoot(screenshooter,
output->output,
output->buffer);
buffer_copy_done = 0;
ms2 = ctimestamp();
while (!buffer_copy_done)
wl_display_roundtrip(display);
fprintf(stderr, "while roundtrip took %llu ms\n", ctimestamp()-ms2);
}
fprintf(stderr, "foreach took %llu ms\n", ctimestamp()-oldMS);
The whole for each block took 901ms to execute, the while loop took 896ms so the majority of the cpu time is spent for waiting for the roundtrip.
Is there any way I could optimize this to get rid of the jitter on the screen? Is calling wl_display_roundtrip in another thread safe? Or is there any async way of doing this?