From 7e6f24552a7e7cdbfbab30c39636dfcb8aabef1e Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 23 Aug 2021 18:29:20 +0300 Subject: [PATCH] Add basic OpenGL info to crash annotations. --- Telegram/SourceFiles/core/application.cpp | 23 +++++++++++++++++++ .../media/view/media_view_overlay_opengl.cpp | 7 ++++++ .../media/view/media_view_overlay_widget.cpp | 3 +++ 3 files changed, 33 insertions(+) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 603f2fb34..cd6636a9f 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_instance.h" #include "mainwidget.h" #include "core/file_utilities.h" +#include "core/crash_reports.h" #include "main/main_account.h" #include "main/main_domain.h" #include "main/main_session.h" @@ -94,6 +95,27 @@ constexpr auto kQuitPreventTimeoutMs = crl::time(1500); constexpr auto kAutoLockTimeoutLateMs = crl::time(3000); constexpr auto kClearEmojiImageSourceTimeout = 10 * crl::time(1000); +void SetCrashAnnotationsGL() { +#ifdef Q_OS_WIN + CrashReports::SetAnnotation("OpenGL ANGLE", [] { + if (Core::App().settings().disableOpenGL()) { + return "Disabled"; + } else switch (Ui::GL::CurrentANGLE()) { + case Ui::GL::ANGLE::Auto: return "Auto"; + case Ui::GL::ANGLE::D3D11: return "Direct3D 11"; + case Ui::GL::ANGLE::D3D9: return "Direct3D 9"; + case Ui::GL::ANGLE::D3D11on12: return "D3D11on12"; + case Ui::GL::ANGLE::OpenGL: return "OpenGL"; + } + Unexpected("Ui::GL::CurrentANGLE value in SetupANGLE."); + }()); +#else // Q_OS_WIN + CrashReports::SetAnnotation( + "OpenGL", + Core::App().settings().disableOpenGL() ? "Disabled" : "Enabled"); +#endif // Q_OS_WIN +} + } // namespace Application *Application::Instance = nullptr; @@ -287,6 +309,7 @@ void Application::run() { LOG(("Shortcuts Error: %1").arg(error)); } + SetCrashAnnotationsGL(); if (!Platform::IsMac() && Ui::GL::LastCrashCheckFailed()) { showOpenGLCrashNotification(); } diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp index fe46890fd..db15fdf5f 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_opengl.cpp @@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/gl/gl_shader.h" #include "media/streaming/media_streaming_common.h" #include "base/platform/base_platform_info.h" +#include "core/crash_reports.h" #include "styles/style_media_view.h" namespace Media::View { @@ -119,6 +120,12 @@ void OverlayWidget::RendererGL::init( FragmentSampleARGB32Texture(), FragmentGlobalOpacity(), })); + + const auto renderer = reinterpret_cast( + f.glGetString(GL_RENDERER)); + CrashReports::SetAnnotation( + "OpenGL Renderer", + renderer ? renderer : "[nullptr]"); } void OverlayWidget::RendererGL::deinit( diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 3832ff42f..e6c42e9f8 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/file_utilities.h" #include "core/mime_type.h" #include "core/ui_integration.h" +#include "core/crash_reports.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/buttons.h" #include "ui/image/image.h" @@ -294,6 +295,8 @@ OverlayWidget::OverlayWidget() , _lastAction(-st::mediaviewDeltaFromLastAction, -st::mediaviewDeltaFromLastAction) , _stateAnimation([=](crl::time now) { return stateAnimationCallback(now); }) , _dropdown(_widget, st::mediaviewDropdownMenu) { + CrashReports::SetAnnotation("OpenGL Renderer", "[not-initialized]"); + Lang::Updated( ) | rpl::start_with_next([=] { refreshLang();