我在armv7设备上使用韦斯顿。我正在使用weston的截屏模块不时地截取屏幕截图,但我注意到的是,当截图被截取时,显示的整个图像会冻结超过一秒钟,这会导致屏幕上出现严重的抖动。
我检查了weston源代码中的screenshot.c代码,并使用一些简单的性能测量(time now - time after)对其进行了编译,发现整个代码中只有一个地方导致了这种抖动:等待wl_display_roundtrip的while循环:
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);整个for每个块的执行时间为901ms,而while循环的执行时间为896ms,因此大部分cpu时间用于等待往返。
有没有什么方法可以优化这个来消除屏幕上的抖动?在另一个线程中调用wl_display_roundtrip是否安全?或者,有没有什么异步的方式可以做到这一点?
发布于 2019-11-21 17:23:28
wayland使用wl_display_roundtrip进行同步响应。此调用将阻塞,直到服务器服务器响应,必须小心使用,因为它可能会减慢系统速度,甚至在最坏的情况下可能会导致死锁。wl_display_roundtrip只在绑定注册表和获取全局对象和绑定时使用一次,因为客户端在没有获取对象接口的情况下无法执行任何操作。
对于非阻塞,您应该使用wl_display_dispatch
https://stackoverflow.com/questions/58587104
复制相似问题