浏览代码

fix multiple window crash

we should not terminate egl_display_, the reason is as follows:
  When calling eglGetPlatformDisplayEXT to get egl_display_, egl will first check a dictionary<platform, egl_display>, if it contains
  a display for the given configuration, it returns the display directly. otherwise it will create a new egl_display and put it into
  the dictionary.
  As the result, if there are more than one uiwidgets_panels in the uiwidgets_system, they will share the same egl_display instance.
  Then when all the panels are disabled at the same time (happens when we hit the play button or close the Editor),the first calling of
  eglTerminate here will uninitiate the shared egl_display instance, making it impossible for the other panels to be disabled properly.
/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
3bebd5ac
共有 1 个文件被更改,包括 12 次插入15 次删除
  1. 27
      engine/src/shell/platform/unity/windows/unity_surface_manager.cc

27
engine/src/shell/platform/unity/windows/unity_surface_manager.cc


void UnitySurfaceManager::CleanUp() {
EGLBoolean result = EGL_FALSE;
if (egl_display_ != EGL_NO_DISPLAY && egl_context_ != EGL_NO_CONTEXT) {
result = eglDestroyContext(egl_display_, egl_context_);
egl_context_ = EGL_NO_CONTEXT;
if (result == EGL_FALSE) {
FML_LOG(ERROR) << "EGL: Failed to destroy context";
}
}
d3d11_device_ = nullptr;
if (egl_display_ != EGL_NO_DISPLAY &&
egl_resource_context_ != EGL_NO_CONTEXT) {
result = eglDestroyContext(egl_display_, egl_resource_context_);

}
}
if (egl_display_ != EGL_NO_DISPLAY) {
result = eglTerminate(egl_display_);
egl_display_ = EGL_NO_DISPLAY;
if (egl_display_ != EGL_NO_DISPLAY && egl_context_ != EGL_NO_CONTEXT) {
result = eglDestroyContext(egl_display_, egl_context_);
egl_context_ = EGL_NO_CONTEXT;
FML_LOG(ERROR) << "EGL : Failed to terminate EGL";
FML_LOG(ERROR) << "EGL: Failed to destroy context";
//TODO: investigate a bit more on the possible memory leak here since egl_display_ will never be released
//refer to the commit log for the details
if (egl_display_ != EGL_NO_DISPLAY) {
egl_display_ = EGL_NO_DISPLAY;
}
d3d11_device_ = nullptr;
}
} // namespace uiwidgets
正在加载...
取消
保存