简体   繁体   English

eglSwapBuffers永远不会返回

[英]eglSwapBuffers never returns

I'm developing a simple game on Raspberry Pi 3. As an operating system I use official Raspbian Stretch Lite. 我正在开发一个关于Raspberry Pi 3的简单游戏。作为一个操作系统,我使用官方的Raspbian Stretch Lite。 The game is run without X server and developed in C++ using SFML PI library. 游戏在没有X服务器的情况下运行,并使用SFML PI库在C ++中开发。

The problem is that game freezes from time to time. 问题是游戏时不时冻结。 It can happen after a few seconds or a few hours of running the game but sooner or later it always happens. 它可以在运行游戏几秒钟或几个小时后发生,但迟早会发生。 The stacktrace of freeze indicates that eglSwapBuffers never returns. 冻结的eglSwapBuffers表明eglSwapBuffers永远不会返回。 What's more killing the game and running it again doesn't help - it freezes during startup on eglCreatePbufferSurface call. 什么更多的杀死游戏并再次运行它没有帮助 - 它在启动期间冻结eglCreatePbufferSurface调用。 It starts again after reboot. 它在重启后重新启动。 What can be the reason of such freeze? 这种冻结的原因是什么? Can I debug it somehow? 我能以某种方式调试它吗? I'm quite afraid that it may be caused by a bug in SFML PI or EGL implementation. 我担心它可能是由SFML PI或EGL实现中的错误引起的。

Stacktrace of main thread during main thread freeze: 主线程冻结期间主线程的堆栈跟踪:

Thread 1 (Thread 0x76293000 (LWP 802)):
#0  0x76f3c014 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=1, 
    futex_word=0x76459b84 <pool_mem+1444>) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x76459b84 <pool_mem+1444>, abstime=0x0) at sem_waitcommon.c:115
#2  0x76f3c158 in __new_sem_wait_slow (sem=0x76459b84 <pool_mem+1444>, abstime=0x0) at sem_waitcommon.c:282
#3  0x76804548 in eglSwapBuffers () from /opt/vc/lib/libbrcmEGL.so
#4  0x76ed14b8 in sf::Window::display() () from /usr/lib/libsfml-window.so.2.4
#5  0x000a8038 in Game::run() ()
#6  0x0013d9ec in main ()

Stacktrace of freeze during startup after killing the game: 杀死游戏后启动期间冻结的Stacktrace:

Thread 1 (Thread 0x76223000 (LWP 1001)):
#0  0x76ecc014 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=1, 
---Type <return> to continue, or q <return> to quit---
    futex_word=0x767c1a58 <khrn_queue+76>) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
#1  do_futex_wait (sem=sem@entry=0x767c1a58 <khrn_queue+76>, abstime=0x0) at sem_waitcommon.c:115
#2  0x76ecc158 in __new_sem_wait_slow (sem=0x767c1a58 <khrn_queue+76>, abstime=0x0) at sem_waitcommon.c:282
#3  0x763eeb60 in vchiu_queue_pop () from /opt/vc/lib/libvchiq_arm.so
#4  0x7679b014 in rpc_recv () from /opt/vc/lib/libbrcmEGL.so
#5  0x76795b54 in egl_surface_create () from /opt/vc/lib/libbrcmEGL.so
#6  0x767923b8 in eglCreatePbufferSurface () from /opt/vc/lib/libbrcmEGL.so
#7  0x76e635f4 in sf::priv::EglContext::EglContext(sf::priv::EglContext*) () from /usr/lib/libsfml-window.so.2.4
#8  0x76e5f2b0 in sf::priv::GlContext::initResource() () from /usr/lib/libsfml-window.so.2.4
#9  0x76e5f95c in sf::GlResource::GlResource() () from /usr/lib/libsfml-window.so.2.4
#10 0x76e60f54 in sf::Window::Window() () from /usr/lib/libsfml-window.so.2.4
#11 0x76ea2d7c in sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) () from /usr/lib/libsfml-graphics.so.2.4
#12 0x000a8642 in Game::Game() ()
#13 0x0013d9e6 in main ()

Disclaimer : This is not a solution, but some step that may help you identify or solve the issue. 免责声明 :这不是一个解决方案,但可以帮助您识别或解决问题。

What's more killing the game and running it again doesn't help 什么更多的杀死游戏并再次运行它并没有帮助

This means that you most likely are facing a driver level issue. 这意味着您很可能面临驱动程序级问题。 Any application problem would be fixed by restarting it (assuming your application runs the same). 任何应用程序问题都可以通过重新启动来解决(假设您的应用程序运行相同)。 And the fact that it freezes, plus references to sem_waitcommon and the look at the stack means, of course, that you are hitting a deadlock, originating from libbrcmEGL.so , the video driver. 它冻结的事实,加上对sem_waitcommon引用以及对堆栈的看法,当然意味着你遇到了死锁,源于视频驱动程序libbrcmEGL.so The bad news is, bugs in the video driver happen, can be pretty complex to solve, and because the driver is closed source, you won't be able to fix it yourself, or have it fixed by the community... 坏消息是,视频驱动程序中的错误发生,解决起来可能非常复杂,而且由于驱动程序是封闭源代码,您将无法自行修复,或者由社区修复...

I wasn't able to find an issue matching yours exactly, which may point toward a bug yet unidentified, due to the specific combination of software and version you are using: 由于您使用的软件和版本的特定组合,我无法找到与您完全匹配的问题,这可能指向尚未识别的错误:

  • Your current distribution: kernel, glibc, cbrm firmware version 您当前的发行版:kernel,glibc,cbrm固件版本
  • Your engine: SFML, SFML PI 您的引擎:SFML,SFML PI
  • And the fact that you are using EGL and not X11 事实上你使用的是EGL,而不是X11

Below are some steps, starting with the easiest 以下是一些步骤,从最简单的开始

Peek at dmesg 偷看dmesg

That is a very easy first step that might yield valuable information. 这是一个非常简单的第一步,可能会产生有价值的信息。 When the issue occurs, after the first and second freeze, see if anything shows up. 出现问题时,在第一次和第二次冻结后,查看是否有任何显示。 Any important issue will be raised there, and shine some light onto your problem. 任何重要的问题都将在那里提出,并为你的问题发光。

Report a bug 报告错误

The first step is probably to report the problem in raspberrypi/linux , with an MVE. 第一步可能是使用MVE报告raspberrypi / linux中的问题。 This may take some time, but maybe your best bet to fix that exact issue, as the firmware of the GPU (Videocore IV, as libbrcmEGL.so ) is closed source. 这可能需要一些时间,但也许是解决这个问题的最佳选择,因为GPU的固件(Videocore IV,如libbrcmEGL.so )是封闭源代码。

SFML / SFML PI SFML / SFML PI

Your bug is probably due to a specific set of operations on the driver that ends up triggering the bug you are seeing. 您的错误可能是由于驱动程序上的一组特定操作导致最终触发您看到的错误。 I would recommend reducing your code to the minimum, to try to identify what triggers the problem. 我建议将代码减少到最小,以尝试确定触发问题的原因。 The fact that it happens randomly won't help, unfortunately. 不幸的是,它随机发生的事实无济于事。 Even though this probably won't solve the core issue, you might be able to circumvent it. 尽管这可能无法解决核心问题,但您可以绕过它。

Try a different version of SFML 尝试使用不同版本的SFML

Either upgrade or downgrade the version of SFML and SFML PI you are using. 升级或降级您正在使用的SFML和SFML PI的版本。 Again, this won't solve the core issue but might avoid it. 同样,这不会解决核心问题,但可能会避免它。

Flash an older Raspbian distribution Flash一个较旧的Raspbian发行版

If this is a regression in the video driver, you might be able to fix it by flashing an older version of the distribution, from here 如果这是视频驱动程序中的回归,您可以通过从此处刷新旧版本的发行版来修复它

To minimize the effort, you can try to manually checkout a different version of libEGL* and libbrcmEGL.so from raspberry/firmware , but you might run into compatibility issues with their dependencies. 为了最大限度地减少工作量,您可以尝试从libbrcmEGL.so / firmware手动检出不同版本的libEGL*libbrcmEGL.so ,但是您可能会遇到与其依赖项的兼容性问题。

Switch to X11 切换到X11

I know... EGL will definitely give you better performances, and you probably don't need that desktop and composition. 我知道...... EGL肯定会给你更好的表现,你可能不需要桌面和合成。 But given the larger community and use, chances are you will run into a lot fewer troubles. 但考虑到更大的社区和使用,你可能会遇到更少的麻烦。 And because it uses libbrcmGLESv2.so , you are guaranteed the same (maybe bugged) code won't be executed. 并且因为它使用了libbrcmGLESv2.so ,所以可以保证不会执行相同的(可能是错误的)代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM