Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

fix(freeze): software UI with NVIDIA overlay/GamePP, engine hang watchdog, bounded exit

Veyra Goal Agentb391b04b287d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ea9fe18b..2a043b5d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1191,7 +1191,7 @@ add_executable(veyra_sr_reconstruction_tests tests/integration/SrReconstructionT
target_link_libraries(veyra_repair_fg_tests PRIVATE veyra_pipeline veyra_sinks veyra_nvof)
# Headless quality-core runner (Playbook R3.3): the phase5 gate's quality
- add_library(veyra_engine STATIC src/engine/EngineController.cpp src/engine/PreviewGpuSession.cpp src/engine/EngineControllerImage.cpp src/engine/PosterFrame.cpp src/engine/EffectChain.cpp src/engine/PresetLibrary.cpp src/ui/PlayerUiFacade.cpp src/engine/TiledImageProcessor.cpp src/engine/PresetStore.cpp src/engine/VideoPresenter.cpp src/engine/VideoExportJob.cpp src/engine/ExportStreams.cpp src/engine/ExportQueue.cpp src/engine/ExportJobManager.cpp src/engine/Subtitles.cpp src/engine/FgCompatibilityProbe.cpp)
+ add_library(veyra_engine STATIC src/engine/EngineController.cpp src/engine/EngineWatchdog.cpp src/engine/PreviewGpuSession.cpp src/engine/EngineControllerImage.cpp src/engine/PosterFrame.cpp src/engine/EffectChain.cpp src/engine/PresetLibrary.cpp src/ui/PlayerUiFacade.cpp src/engine/TiledImageProcessor.cpp src/engine/PresetStore.cpp src/engine/VideoPresenter.cpp src/engine/VideoExportJob.cpp src/engine/ExportStreams.cpp src/engine/ExportQueue.cpp src/engine/ExportJobManager.cpp src/engine/Subtitles.cpp src/engine/FgCompatibilityProbe.cpp)
target_sources(veyra_pipeline PRIVATE src/guidance/AmdOpticalFlow.cpp
src/guidance/GpuDisOpticalFlow.cpp third_party/gpu-dis/src/gpu/native_strict_dis_provider.cpp)
target_include_directories(veyra_pipeline PRIVATE third_party/gpu-dis/src/gpu)
diff --git a/apps/veyra-qml/main.cpp b/apps/veyra-qml/main.cpp
index 03a9e04d..243953a9 100644
--- a/apps/veyra-qml/main.cpp
+++ b/apps/veyra-qml/main.cpp
@@ -441,6 +441,7 @@ static int runApplication(int argc, char** argv, QString& restartProgram, QStrin
(void)veyra::Logger::instance().openFile(logPath.wstring(), true);
}
g_crashDumpDirectory = logPath.parent_path().wstring();
+ veyra::engine::EngineWatchdog::setDumpDirectory(g_crashDumpDirectory);
SetUnhandledExceptionFilter(crashFilter);
// Interface scale (设置 → 界面缩放) has to be fixed before Qt starts, so the
@@ -498,8 +499,15 @@ static int runApplication(int argc, char** argv, QString& restartProgram, QStrin
// changes in server detection cannot turn that restart into another prompt.
const bool rivaTuner = !GetEnvironmentVariableW(L"VEYRA_TEST_IGNORE_RTSS", nullptr, 0)
&& veyra::gfx::rivaTunerRunning();
+ // NVIDIA's in-game overlay and GamePP (游戏加加) hook every swapchain too; with the
+ // interface on D3D12 next to the video, the two presenting threads deadlocked in the
+ // field (logs(15)) and GamePP broke every resize (see gfx/PresentationHooks.h).
+ // VEYRA_TEST_IGNORE_NVIDIA_OVERLAY / VEYRA_TEST_IGNORE_GAMEPP start as if they were off.
+ const bool nvidiaOverlay = !GetEnvironmentVariableW(L"VEYRA_TEST_IGNORE_NVIDIA_OVERLAY", nullptr, 0)
+ && veyra::gfx::nvidiaOverlayRunning();
+ const bool gamePP = !GetEnvironmentVariableW(L"VEYRA_TEST_IGNORE_GAMEPP", nullptr, 0) && veyra::gfx::gamePPRunning();
const bool overlayCompat = !obsGameCapture && overlayCompatAuto
- && (rivaTuner || overlayCompatRestart) && !forcedRenderer[0];
+ && (rivaTuner || nvidiaOverlay || gamePP || overlayCompatRestart) && !forcedRenderer[0];
const bool softwareUi = obsGameCapture || overlayCompat;
if (softwareUi) {
// Partial software damage updates can leave transformed/clipped controls
@@ -513,8 +521,8 @@ static int runApplication(int argc, char** argv, QString& restartProgram, QStrin
veyra::log::info("app", "OBS game capture compatibility: software UI; native D3D12 video unchanged");
} else if (overlayCompat) {
QQuickWindow::setSceneGraphBackend(QStringLiteral("software"));
- veyra::log::info("app", std::format("RTSS compatibility: software UI; activeServer={} acceptedRestart={}; native D3D12 video unchanged",
- rivaTuner, overlayCompatRestart));
+ veyra::log::info("app", std::format("RTSS compatibility: software UI; activeServer={} nvidiaOverlay={} gamePP={} acceptedRestart={}; native D3D12 video unchanged",
+ rivaTuner, nvidiaOverlay, gamePP, overlayCompatRestart));
}
{
// A GPU interface keeps RTSS from drawing in this process at all, so a RivaTuner
@@ -529,6 +537,7 @@ static int runApplication(int argc, char** argv, QString& restartProgram, QStrin
else if (!gpuD3d12 && ours) SetEnvironmentVariableW(veyra::gfx::kRivaTunerProfileOverride, nullptr);
veyra::log::info("app", std::format("RivaTuner running={} injected={} compat={} OSD in this process={}", rivaTuner,
GetModuleHandleW(L"RTSSHooks64.dll") != nullptr, overlayCompatAuto ? "auto" : "off", gpuD3d12 ? "off (GPU interface)" : "on"));
+ veyra::log::info("app", std::format("NVIDIA overlay running={} GamePP running={} interface={}", nvidiaOverlay, gamePP, softwareUi ? "software" : "GPU"));
}
QApplication app(argc, argv);
// Qt does not automatically use the executable's Win32 icon for its windows.
diff --git a/i18n/catalog.json b/i18n/catalog.json
index d0a43788..5ece954a 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -4076,11 +4076,11 @@
"ja": "起動時に前回の再生を再開"
},
{
- "zh": "启动时检测到小飞机(RTSS)就改用软件绘制界面,OSD 只显示在视频上",
+ "zh": "启动时检测到小飞机(RTSS)、NVIDIA 信息浮窗或游戏加加就改用软件绘制界面,它们只显示在视频上",
"src": "qml/SettingsPage.qml",
- "zh-TW": "啟動時偵測到小飛機(RTSS)就改用軟體繪製介面,OSD 只顯示在影片上",
- "en": "When RivaTuner (RTSS) is running at start, the interface is drawn in software and the OSD shows on the video only",
- "ja": "起動時に RivaTuner(RTSS)を検出するとインターフェースをソフトウェア描画にし、OSD は映像にだけ表示します"
+ "zh-TW": "啟動時偵測到小飛機(RTSS)、NVIDIA 遊戲內覆疊或遊戲加加就改用軟體繪製介面,它們只顯示在影片上",
+ "en": "When RivaTuner (RTSS), NVIDIA's in-game overlay or GamePP is running at start, the interface is drawn in software and they show on the video only",
+ "ja": "起動時に RivaTuner(RTSS)、NVIDIA オーバーレイ、GamePP を検出するとインターフェースをソフトウェア描画にし、それらは映像にだけ表示されます"
},
{
"zh": "启动时预热增强组件",
@@ -8437,6 +8437,27 @@
"en": "RTSS on-screen display service detected",
"ja": "RTSS オンスクリーン表示サービスを検出"
},
+ {
+ "zh": "检测到 %1",
+ "src": "qml/Main.qml",
+ "zh-TW": "偵測到 %1",
+ "en": "%1 detected",
+ "ja": "%1 を検出"
+ },
+ {
+ "zh": "NVIDIA 信息浮窗",
+ "src": "qml/Main.qml",
+ "zh-TW": "NVIDIA 遊戲內覆疊",
+ "en": "NVIDIA in-game overlay",
+ "ja": "NVIDIA オーバーレイ"
+ },
+ {
+ "zh": "游戏加加(GamePP)",
+ "src": "qml/Main.qml",
+ "zh-TW": "遊戲加加(GamePP)",
+ "en": "GamePP",
+ "ja": "GamePP(游戏加加)"
+ },
{
"zh": "检测到 RTSS 屏显服务正在运行。开启兼容绘制需重启 Veyra,重启后 OSD 仅显示在视频上。现在重启吗?当前播放或串流将停止。",
"src": "qml/Main.qml",
@@ -8444,6 +8465,13 @@
"en": "The RTSS on-screen display service is running. Restart Veyra to enable compatible rendering and show the OSD on the video only. Restart now? Current playback or streaming will stop.",
"ja": "RTSS オンスクリーン表示サービスが動作しています。互換描画を有効にするには Veyra を再起動してください。再起動後、OSD は映像にだけ表示されます。今すぐ再起動しますか?再生中の映像やストリーミングは停止します。"
},
+ {
+ "zh": "%1 正在运行。它会同时挂接界面和视频两个画面,可能让 Veyra 卡死;开启兼容绘制需重启 Veyra,重启后界面改用软件绘制,它只作用在视频上。现在重启吗?当前播放或串流将停止。",
+ "src": "qml/Main.qml",
+ "zh-TW": "%1 正在執行。它會同時掛接介面和影片兩個畫面,可能讓 Veyra 卡死;啟用相容繪製需重新啟動 Veyra,重新啟動後介面改用軟體繪製,它只作用在影片上。現在重新啟動嗎?目前的播放或串流將停止。",
+ "en": "%1 is running. It hooks both the interface and the video, which can freeze Veyra. Restart Veyra to enable compatible rendering: the interface is then drawn in software and %1 only affects the video. Restart now? Current playback or streaming will stop.",
+ "ja": "%1 が動作しています。インターフェースと映像の両方にフックするため、Veyra がフリーズすることがあります。互換描画を有効にするには Veyra を再起動してください。再起動後はインターフェースをソフトウェアで描画し、%1 は映像にだけ作用します。今すぐ再起動しますか?再生中の映像やストリーミングは停止します。"
+ },
{
"zh": "检测到 RivaTuner(小飞机 OSD)注入了 Veyra。请把 设置 → 监控软件兼容 设为“自动”并在小飞机运行时重启 Veyra:界面改用兼容绘制,OSD 只显示在视频上",
"src": "src/ui/QmlPlayerBridge.cpp",
@@ -9480,6 +9508,13 @@
"en": "The picture plays in the main window",
"ja": "映像はメインウィンドウで再生されます"
},
+ {
+ "zh": "画面引擎无响应,已记录诊断信息;如画面未恢复,请关闭软件后重新打开",
+ "src": "include/veyra/engine/EngineWatchdog.h",
+ "zh-TW": "畫面引擎無回應,已記錄診斷資訊;如畫面未恢復,請關閉軟體後重新開啟",
+ "en": "The picture engine stopped responding; diagnostics were recorded. If the picture does not recover, close and reopen Veyra.",
+ "ja": "映像エンジンが応答しません。診断情報を記録しました。映像が回復しない場合は、ソフトを閉じて開き直してください。"
+ },
{
"zh": "画面比例",
"src": "qml/ProPage.qml",
@@ -9502,11 +9537,11 @@
"ja": "画質調整が時間方向の安定化を制御中。オフにするとこの設定に戻ります。"
},
{
- "zh": "界面始终用显卡绘制;为避免冲突,小飞机 OSD 不在 Veyra 里显示",
+ "zh": "界面始终用显卡绘制;小飞机 OSD 不在 Veyra 里显示;开着 NVIDIA 信息浮窗或游戏加加时可能卡死",
"src": "qml/SettingsPage.qml",
- "zh-TW": "介面始終用顯示卡繪製;為避免衝突,小飛機 OSD 不在 Veyra 中顯示",
- "en": "The interface always draws on the GPU; to avoid a conflict the RTSS OSD is not shown in Veyra",
- "ja": "インターフェースは常に GPU で描画します。競合を避けるため RTSS の OSD は Veyra に表示しません"
+ "zh-TW": "介面始終用顯示卡繪製;小飛機 OSD 不在 Veyra 中顯示;開著 NVIDIA 遊戲內覆疊或遊戲加加時可能卡死",
+ "en": "The interface always draws on the GPU; the RTSS OSD is not shown in Veyra; with NVIDIA's in-game overlay or GamePP running, Veyra may freeze",
+ "ja": "インターフェースは常に GPU で描画します。RTSS の OSD は Veyra に表示しません。NVIDIA オーバーレイや GamePP が動作しているとフリーズすることがあります"
},
{
"zh": "界面状态写入失败",
diff --git a/include/veyra/diagnostics/CpuStallTrace.h b/include/veyra/diagnostics/CpuStallTrace.h
index 087a6786..64e7d65a 100644
--- a/include/veyra/diagnostics/CpuStallTrace.h
+++ b/include/veyra/diagnostics/CpuStallTrace.h
@@ -1,6 +1,7 @@
#pragma once
#include "veyra/Log.h"
#include <array>
+#include <atomic>
#include <chrono>
#include <cstdint>
#include <format>
@@ -11,9 +12,12 @@ namespace veyra::diagnostics {
class CpuStallTrace {
using Clock = std::chrono::steady_clock;
public:
- explicit CpuStallTrace(const char* component, uint64_t frame = 0, double thresholdMs = 80.0)
- : component_(component), frame_(frame), thresholdMs_(thresholdMs) {}
+ // stage, when given, receives each mark (string literals) for a watchdog.
+ explicit CpuStallTrace(const char* component, uint64_t frame = 0, double thresholdMs = 80.0,
+ std::atomic<const char*>* stage = nullptr)
+ : component_(component), frame_(frame), thresholdMs_(thresholdMs), stage_(stage) {}
void mark(const char* stage) {
+ if (stage_) stage_->store(stage, std::memory_order_relaxed);
const auto now = Clock::now();
if (count_ < samples_.size()) samples_[count_++] = {stage, ms(now - last_)};
last_ = now;
@@ -33,6 +37,7 @@ private:
const char* component_;
uint64_t frame_;
double thresholdMs_;
+ std::atomic<const char*>* stage_;
Clock::time_point start_ = Clock::now(), last_ = start_;
std::array<Sample, 32> samples_{};
size_t count_ = 0;
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index 69eea557..c8078f84 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -12,6 +12,7 @@
#include "veyra/engine/PresentationSettings.h"
#include "veyra/diagnostics/FrameMetrics.h"
#include "veyra/engine/PreviewView.h"
+#include "veyra/engine/EngineWatchdog.h"
#include "veyra/sink/CaptureAudioSession.h"
#include "veyra/remoteplay/SessionInbox.h"
#ifdef VEYRA_ENABLE_MOONLIGHT
@@ -194,6 +195,7 @@ private:
void post(std::function<void()>);
void dispatch();
void status(const std::wstring&,bool failed=false);
+ void noteEngineHang(uint64_t stalledMs);
mutable std::mutex mutex_;
PlayerSnapshot snapshot_;
PresentationSettings presentation_;
@@ -208,6 +210,10 @@ private:
std::unique_ptr<PreviewGpuSession> prewarmed_; // engine dispatcher only
std::atomic<bool> prewarmEnabled_{false}; // off until the saved preference enables it (default off since 2026-10-05)
std::condition_variable wake_;std::function<void()> pending_;bool shutdown_=false,busy_=false;
+ // Owner-thread stall detection (field logs(15)); created before worker_ starts.
+ std::unique_ptr<EngineWatchdog> watchdog_;
+ std::condition_variable dispatchDone_;bool dispatchExited_=false; // mutex_
+ std::wstring hangPreviousStatus_; // mutex_
EnhancementSettings desired_;uint64_t nextRevision_=1;
std::optional<ChainRuntimeOrder> desiredNodeOrder_; // protected by mutex_, paired with desired_
std::atomic<bool> stop_{false},paused_{false},muted_{false};
diff --git a/include/veyra/engine/EngineWatchdog.h b/include/veyra/engine/EngineWatchdog.h
new file mode 100644
index 00000000..7bd1a30a
--- /dev/null
+++ b/include/veyra/engine/EngineWatchdog.h
@@ -0,0 +1,40 @@
+#pragma once
+#include <atomic>
+#include <cstdint>
+#include <functional>
+#include <memory>
+#include <string>
+
+namespace veyra::engine {
+// Engine status while a stall is being reported (the bridge raises it once).
+inline constexpr wchar_t kEngineHangStatus[] = L"画面引擎无响应,已记录诊断信息;如画面未恢复,请关闭软件后重新打开";
+// Field logs(15), 2026-10-10: the engine owner thread stopped without a single
+// log line while capture, audio and the interface kept running, and closing the
+// app then waited for that thread forever. The watchdog notices an owner thread
+// that stops making progress inside the playback loop, logs where it is blocked
+// (call stack as module + offset and nearest export) and writes one small
+// minidump beside the log, so the next report names the blocking call. Shutdown
+// asks hung() so it can stop waiting for a thread that will not return.
+class EngineWatchdog {
+public:
+ // Interface notice: stalledMs > 0 while blocked, 0 once the loop moves again.
+ using Notify = std::function<void(uint64_t stalledMs)>;
+ explicit EngineWatchdog(Notify notify);
+ ~EngineWatchdog();
+ EngineWatchdog(const EngineWatchdog&) = delete;
+ EngineWatchdog& operator=(const EngineWatchdog&) = delete;
+ // Owner thread, top of every playback-loop iteration.
+ void beat();
+ // Owner thread, when it leaves the playback loop.
+ void disarm();
+ // Last completed loop stage (string literals only), written by CpuStallTrace.
+ std::atomic<const char*>* stage();
+ // A reported stall is still in progress.
+ bool hung() const;
+ // Where veyra-hang-*.dmp goes (the log directory); empty means no dump.
+ static void setDumpDirectory(const std::wstring& directory);
+private:
+ struct State;
+ std::shared_ptr<State> state_;
+};
+}
diff --git a/include/veyra/gfx/PresentationHooks.h b/include/veyra/gfx/PresentationHooks.h
index abf6162f..7468ca93 100644
--- a/include/veyra/gfx/PresentationHooks.h
+++ b/include/veyra/gfx/PresentationHooks.h
@@ -80,6 +80,51 @@ inline bool rivaTunerRunning() {
return live;
}
+// A running process whose image name satisfies match.
+template <class Match> inline bool processRunning(Match match) {
+ const HANDLE raw = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+ if (raw == INVALID_HANDLE_VALUE) return false;
+ struct Snapshot { HANDLE handle; ~Snapshot() { CloseHandle(handle); } } snapshot{raw};
+ PROCESSENTRY32W process{};
+ process.dwSize = sizeof(process);
+ for (BOOL found = Process32FirstW(snapshot.handle, &process); found;
+ found = Process32NextW(snapshot.handle, &process))
+ if (match(process.szExeFile)) return true;
+ return false;
+}
+
+// NVIDIA's in-game overlay is switched on: NVIDIA App's "NVIDIA 信息浮窗" runs
+// NVIDIA Overlay.exe, GeForce Experience's in-game overlay runs NVIDIA Share.exe; both
+// exit when the overlay is switched off. nvspcap64.dll alone says nothing: the driver
+// loads it into every Direct3D process whether or not the overlay is on.
+//
+// Why it matters (field logs(15), 2026-10-10, RTX 5060 Ti, driver 617.42): during
+// capture the engine's video thread and the interface thread stopped at the same moment
+// in 10 of 12 freezes (a deadlock between the two presenting threads), and users report
+// that 2.0+ freezes within seconds of starting capture with the overlay on and never
+// with it off; 1.4.4, whose interface had no swapchain, did not. Like RTSS, the overlay
+// hooks every swapchain in the process; with the interface drawn in software only the
+// video's swapchain remains. Not reproduced on an RTX 5070 / 616.56 (overlay on, D3D12
+// interface, DLSS frame generation, HDR output, 45 s).
+inline bool nvidiaOverlayRunning() {
+ return processRunning([](const wchar_t* name) {
+ return _wcsicmp(name, L"NVIDIA Overlay.exe") == 0 || _wcsicmp(name, L"NVIDIA Share.exe") == 0;
+ });
+}
+
+// GamePP (游戏加加, GamePP.exe and its GamePP* helpers) injects GPP64.dll (overlay),
+// GameTracker64.dll and shade64.dll (filters) into programs it treats as games. Field
+// dump 2026-10-01: with them injected, the video's and the interface's swapchains both
+// failed every ResizeBuffers and the driver crashed on a window change; the same
+// two-swapchain hooking as RTSS and NVIDIA's overlay. Detected by process at start,
+// since the modules only arrive after the interface's window exists.
+inline bool gamePPRunning() {
+ return processRunning([](const wchar_t* name) { return _wcsnicmp(name, L"GamePP", 6) == 0; });
+}
+inline bool gamePPInjected() {
+ return GetModuleHandleW(L"GPP64.dll") || GetModuleHandleW(L"GameTracker64.dll") || GetModuleHandleW(L"shade64.dll");
+}
+
// RTSS reads this variable from the process it hooks whenever it (re)loads its profile for
// it ("Name,value[,Name,value…]", RTSSHooks64.dll); EnableOSD is one of the properties it
// accepts. With EnableOSD,0 it still counts frames but never draws in this process.
diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.h
index 0dfb0907..c69cea70 100644
--- a/include/veyra/ui/QmlPlayerBridge.h
+++ b/include/veyra/ui/QmlPlayerBridge.h
@@ -667,6 +667,9 @@ public:
bool overlayCompatActive() const;
// RivaTuner Statistics Server is running now (gfx::rivaTunerRunning).
Q_INVOKABLE bool rivaTunerRunning() const;
+ // An overlay that 监控软件兼容 reacts to is running now: RTSS, NVIDIA's in-game overlay
+ // or GamePP (gfx/PresentationHooks.h).
+ Q_INVOKABLE bool presentationOverlayRunning() const;
Q_INVOKABLE void openFeedbackPage();
Q_INVOKABLE void openReleasesPage();
QVariantList audioDevices() const;
@@ -1115,9 +1118,10 @@ signals:
// User-facing notices the UI shows as a transient message: a rejected
// chain edit, an export that finished, a failed open.
void notice(const QString& text, bool isError);
- // RivaTuner injected into a run whose interface draws on the GPU: its OSD is kept out
- // of this process until a restart switches the interface to software drawing.
- void overlayRestartSuggested();
+ // A presentation-hooking overlay appeared in a run whose interface draws on the GPU
+ // ("rtss": its OSD is kept out of this process; "nvidia": NVIDIA's in-game overlay and
+ // "gamepp": GamePP, which cannot be kept out); a restart draws the interface in software.
+ void overlayRestartSuggested(const QString& kind);
// The UI moves to a page by name when a command implies it.
void navigate(const QString& page);
diff --git a/qml/Veyra/Main.qml b/qml/Veyra/Main.qml
index 442ff0b9..346945e2 100644
--- a/qml/Veyra/Main.qml
+++ b/qml/Veyra/Main.qml
@@ -680,12 +680,17 @@ Window {
}
}
- // RivaTuner started after Veyra: its OSD is kept out until a restart (QmlPlayerBridge).
+ // RivaTuner, NVIDIA's overlay or GamePP started after Veyra (QmlPlayerBridge): RTSS's
+ // OSD is kept out until a restart; the other two cannot be, and froze 2.0 in the field.
VConfirm {
id: overlayRestart
objectName: "overlay-restart-confirm"
- title: qsTr("检测到 RTSS 屏显服务")
- text: qsTr("检测到 RTSS 屏显服务正在运行。开启兼容绘制需重启 Veyra,重启后 OSD 仅显示在视频上。现在重启吗?当前播放或串流将停止。")
+ property string kind: "rtss"
+ readonly property string product: kind === "nvidia" ? qsTr("NVIDIA 信息浮窗") : qsTr("游戏加加(GamePP)")
+ title: kind === "rtss" ? qsTr("检测到 RTSS 屏显服务") : qsTr("检测到 %1").arg(product)
+ text: kind === "rtss"
+ ? qsTr("检测到 RTSS 屏显服务正在运行。开启兼容绘制需重启 Veyra,重启后 OSD 仅显示在视频上。现在重启吗?当前播放或串流将停止。")
+ : qsTr("%1 正在运行。它会同时挂接界面和视频两个画面,可能让 Veyra 卡死;开启兼容绘制需重启 Veyra,重启后界面改用软件绘制,它只作用在视频上。现在重启吗?当前播放或串流将停止。").arg(product)
acceptText: qsTr("重启")
rejectText: qsTr("稍后")
onAccepted: veyra.restartForOverlayCompatibility()
@@ -695,7 +700,7 @@ Window {
target: veyra
function onPlaylistRequested() { playlistWindow.open() }
function onNotice(text, isError) { toast.show(text, isError) }
- function onOverlayRestartSuggested() { overlayRestart.open() }
+ function onOverlayRestartSuggested(kind) { overlayRestart.kind = kind; overlayRestart.open() }
function onNavigate(p) {
// A dialog key opens the dialog; anything else is a page.
if (p === "capture" || p === "ps5" || p === "moonlight" || p === "xbox" || p === "screen"
diff --git a/qml/Veyra/SettingsPage.qml b/qml/Veyra/SettingsPage.qml
index 073aadcb..186f403c 100644
--- a/qml/Veyra/SettingsPage.qml
+++ b/qml/Veyra/SettingsPage.qml
@@ -685,19 +685,20 @@ VPage {
}
}
VRow {
- // RivaTuner (MSI Afterburner's OSD): see main.cpp. Auto draws the interface in
- // software when RTSS runs at start, so its OSD only sits on the video.
+ // RivaTuner (MSI Afterburner's OSD), NVIDIA's in-game overlay and GamePP: see
+ // main.cpp. Auto draws the interface in software when one runs at start, so
+ // they only hook the video.
readonly property bool automatic: (veyra.preferences.overlayCompat || "auto") === "auto"
label: qsTr("监控软件兼容")
hint: veyra.obsGameCaptureActive
? qsTr("OBS 游戏采集兼容已让界面软件绘制,小飞机 OSD 只显示在视频上")
- : (automatic !== veyra.overlayCompatActive && (veyra.overlayCompatActive || veyra.rivaTunerRunning()))
+ : (automatic !== veyra.overlayCompatActive && (veyra.overlayCompatActive || veyra.presentationOverlayRunning()))
? qsTr("重启后生效")
: veyra.overlayCompatActive
? qsTr("监控兼容绘制已启用:OSD 只显示在视频上;部分阴影与模糊简化")
: automatic
- ? qsTr("启动时检测到小飞机(RTSS)就改用软件绘制界面,OSD 只显示在视频上")
- : qsTr("界面始终用显卡绘制;为避免冲突,小飞机 OSD 不在 Veyra 里显示")
+ ? qsTr("启动时检测到小飞机(RTSS)、NVIDIA 信息浮窗或游戏加加就改用软件绘制界面,它们只显示在视频上")
+ : qsTr("界面始终用显卡绘制;小飞机 OSD 不在 Veyra 里显示;开着 NVIDIA 信息浮窗或游戏加加时可能卡死")
VSeg {
objectName: "set-overlay-compat"
options: [{ id: "auto", label: qsTr("自动") }, { id: "off", label: qsTr("关闭") }]
@@ -705,7 +706,7 @@ VPage {
onPicked: id => {
if (veyra.setPreference("overlayCompat", id) && !veyra.obsGameCaptureActive
&& (id === "auto") !== veyra.overlayCompatActive
- && (veyra.overlayCompatActive || veyra.rivaTunerRunning()))
+ && (veyra.overlayCompatActive || veyra.presentationOverlayRunning()))
obsRestart.open()
}
}
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 113a9732..8f8f8f50 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -73,14 +73,42 @@ void logFrameFlow(const diagnostics::FrameFlowMetrics& m,const char* state){
veyra::log::info("frame-flow",std::format("state={} session={} revision={} epoch={} source={} batch={} readyFence={} consumerFence={} captureReceived={} mailboxOverwritten={} sourceAccepted={} sourceSkippedBeforeGraph={} realSubmitted={} fgCandidate={} fgSkippedBeforeEval={} fgEvaluated={} fgWarmup={} fgSkippedForReset={} fgReduced={} fgReadyValid={} fgInvalid={} realPresented={} generatedPresented={} generatedExpiredAfterEval={} cancelledBeforePresent={} commandSlots={} commandHighWater={} presentationHighWater={} slotWaitCount={} slotWaitMs={:.3f} generatedFps={:.2f} presentSubmitFps={:.2f} resetRevision={} resetEpoch={} resetReason={} resetOutcome={} resetDrainMs={:.3f} resetDestroyMs={:.3f} resetCreateMs={:.3f} resetWarmupMs={:.3f} resetFirstValidMs={:.3f} resetTotalMs={:.3f}",state,id.sessionId,id.frame.settingsRevision,id.frame.epoch,id.frame.sourceFrameId,id.batchId,id.readyFence,id.consumerFence,c.captureReceived,c.mailboxOverwritten,c.sourceAccepted,c.sourceSkippedBeforeGraph,c.realSubmitted,c.fgCandidate,c.fgSkippedBeforeEval,c.fgEvaluated,c.fgWarmup,c.fgSkippedForReset,c.fgReduced,c.fgReadyValid,c.fgInvalid,c.realPresented,c.generatedPresented,c.generatedExpiredAfterEval,c.cancelledBeforePresent,c.commandSlotsInFlight,c.commandSlotHighWater,c.presentationBatchHighWater,m.slotReuseWaitCount,m.slotReuseWaitMs.value_or(0),m.validGeneratedFps,m.presentSubmitFps,r.settingsRevision,r.epoch,unsigned(r.reason),unsigned(r.outcome),ms(diagnostics::ResetStage::Drain),ms(diagnostics::ResetStage::Destroy),ms(diagnostics::ResetStage::Create),ms(diagnostics::ResetStage::Warmup),ms(diagnostics::ResetStage::FirstValid),r.totalMs.value_or(-1.0)));
}
}
-EngineController::EngineController(){worker_=std::thread(&EngineController::dispatch,this);}
-EngineController::~EngineController(){ {std::lock_guard lock(mutex_);shutdown_=true;pending_={};stop_=true;}wake_.notify_one();if(worker_.joinable())worker_.join(); }
+EngineController::EngineController(){
+ watchdog_=std::make_unique<EngineWatchdog>([this](uint64_t stalledMs){noteEngineHang(stalledMs);});
+ worker_=std::thread(&EngineController::dispatch,this);
+}
+EngineController::~EngineController(){
+ {std::lock_guard lock(mutex_);shutdown_=true;pending_={};stop_=true;}wake_.notify_one();
+ if(!worker_.joinable())return;
+ // Field logs(15): an owner thread blocked inside a driver call never returns,
+ // and closing the app waited for it forever (the process had to be killed).
+ // Wait a bounded time, then end the process instead of hanging on exit.
+ const auto started=Clock::now();
+ {std::unique_lock lock(mutex_);
+ while(!dispatchDone_.wait_for(lock,std::chrono::milliseconds(100),[&]{return dispatchExited_;})){
+ const double waited=elapsedMs(started);
+ if(waited<(watchdog_->hung()?3000.0:20000.0))continue;
+ veyra::log::error("engine-hang",std::format("shutdown: owner thread still blocked after {:.0f} ms; ending the process instead of waiting",waited));
+ Logger::instance().flush();
+ TerminateProcess(GetCurrentProcess(),0);
+ }
+ }
+ worker_.join();
+}
void EngineController::dispatch(){
for(;;){std::function<void()> task;{std::unique_lock lock(mutex_);wake_.wait(lock,[&]{return shutdown_||bool(pending_);});if(shutdown_)break;task=std::move(pending_);pending_={};busy_=true;stop_=false;}
try{task();}catch(const std::exception&){status(L"任务异常,已停止;请查看诊断",true);}
{std::lock_guard lock(mutex_);busy_=false;snapshot_.running=false;if(snapshot_.transport==TransportState::Stopping)snapshot_.transport=TransportState::Empty;}
}
prewarmed_.reset();
+ {std::lock_guard lock(mutex_);dispatchExited_=true;}dispatchDone_.notify_all();
+}
+// Watchdog thread. try_lock: an owner stuck while holding mutex_ must not take
+// the watchdog down with it.
+void EngineController::noteEngineHang(uint64_t stalledMs){
+ std::unique_lock lock(mutex_,std::try_to_lock);if(!lock.owns_lock())return;
+ if(stalledMs){if(snapshot_.status!=kEngineHangStatus){hangPreviousStatus_=snapshot_.status;snapshot_.status=kEngineHangStatus;}}
+ else if(snapshot_.status==kEngineHangStatus)snapshot_.status=hangPreviousStatus_;
}
void EngineController::post(std::function<void()> task){ {std::lock_guard lock(mutex_);stop_=true;pending_=std::move(task);}wake_.notify_one(); }
bool EngineController::idle()const{std::lock_guard lock(mutex_);return !busy_&&!pending_;}
@@ -1140,6 +1168,13 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
reset=true;pendingResetCause=pipeline::ResetReason::Settings;
return true;
};
+ // Disarmed after stopPresentation's teardown, so a teardown that blocks is
+ // reported too.
+ OnExit leaveWatchdog{[&]{watchdog_->disarm();}};
+ // Test hook: block the owner once, after 120 loop frames, for the given ms
+ // (-1 = forever), to exercise the hang watchdog and bounded shutdown.
+ wchar_t testHangText[16]{};
+ int testHangMs=GetEnvironmentVariableW(L"VEYRA_TEST_ENGINE_HANG_MS",testHangText,16)?_wtoi(testHangText):0;
// Declared LAST before the loop on purpose: it is destroyed first at
// scope exit, so the scheduler (whose queued step/finish lambdas
// capture the locals above by reference) is torn down before any of
@@ -1149,10 +1184,12 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
uint64_t autoNrRevision=options.settings.revision;int64_t autoNrLogAt=0;
OnExit stopPresentation{[&]{liveScheduler.reset();finishReset(stop_?diagnostics::ResetOutcome::Cancelled:diagnostics::ResetOutcome::Failed);std::lock_guard lock(mutex_);if(snapshot_.sessionId==runSessionId){if(frameFlow)snapshot_.metrics.flow=frameFlow->snapshot(host100ns());activeFlow_.reset();}}};
while(!stop_){
+ watchdog_->beat();
+ if(testHangMs&&frames>=120){veyra::log::warn("engine-test",std::format("blocking owner thread for {} ms",testHangMs));Sleep(testHangMs<0?INFINITE:DWORD(testHangMs));testHangMs=0;}
if(Clock::now()-cacheBudgetPolledAt>=std::chrono::milliseconds(500)){
(void)recentGraphCache.checkBudget();cacheBudgetPolledAt=Clock::now();
}
- diagnostics::CpuStallTrace loopTrace("engine-stall",frames,45.0);
+ diagnostics::CpuStallTrace loopTrace("engine-stall",frames,45.0,watchdog_->stage());
collectTimings();
loopTrace.mark("collect");
if(captureRecovering){
diff --git a/src/engine/EngineWatchdog.cpp b/src/engine/EngineWatchdog.cpp
new file mode 100644
index 00000000..6630d458
--- /dev/null
+++ b/src/engine/EngineWatchdog.cpp
@@ -0,0 +1,268 @@
+#include "veyra/engine/EngineWatchdog.h"
+
+#include <windows.h>
+#include <dbghelp.h>
+
+#include <chrono>
+#include <condition_variable>
+#include <cstring>
+#include <filesystem>
+#include <format>
+#include <mutex>
+#include <thread>
+
+#include "veyra/Log.h"
+#include "veyra/gfx/PresentationHooks.h"
+
+namespace veyra::engine {
+namespace {
+// Long enough for graph rebuilds and runtime/model loading inside one loop
+// iteration; a healthy loop beats every few milliseconds.
+constexpr uint64_t kReportMs = 8000;
+constexpr unsigned kMaxFrames = 48;
+
+std::mutex g_dumpMutex;
+std::wstring g_dumpDirectory;
+std::atomic<int> g_dumpsWritten{0};
+
+struct StackSample { uintptr_t pc[kMaxFrames]; unsigned count; };
+
+// The owner is suspended while this runs: no allocation, no locks, no logging.
+__declspec(noinline) void unwindSuspended(CONTEXT* context, StackSample* out) {
+ __try {
+ while (out->count < kMaxFrames && context->Rip) {
+ out->pc[out->count++] = context->Rip;
+ DWORD64 imageBase = 0;
+ const PRUNTIME_FUNCTION function = RtlLookupFunctionEntry(context->Rip, &imageBase, nullptr);
+ if (function) {
+ PVOID handlerData = nullptr; DWORD64 establisherFrame = 0;
+ RtlVirtualUnwind(UNW_FLAG_NHANDLER, imageBase, context->Rip, function, context, &handlerData, &establisherFrame, nullptr);
+ } else {
+ context->Rip = *reinterpret_cast<const DWORD64*>(context->Rsp);
+ context->Rsp += 8;
+ }
+ }
+ } __except (EXCEPTION_EXECUTE_HANDLER) {}
+}
+
+bool sampleThread(HANDLE thread, StackSample& out) {
+ out.count = 0;
+ if (SuspendThread(thread) == DWORD(-1)) return false;
+ CONTEXT context{};
+ context.ContextFlags = CONTEXT_FULL;
+ const bool ok = GetThreadContext(thread, &context) != FALSE;
+ if (ok) unwindSuspended(&context, &out);
+ ResumeThread(thread);
+ return ok;
+}
+
+uint64_t threadCpuMs(HANDLE thread) {
+ FILETIME created{}, exited{}, kernel{}, user{};
+ if (!GetThreadTimes(thread, &created, &exited, &kernel, &user)) return 0;
+ const auto value = [](FILETIME t) { return (uint64_t(t.dwHighDateTime) << 32) | t.dwLowDateTime; };
+ return (value(kernel) + value(user)) / 10000;
+}
+
+// Nearest named export at or below rva: names the system/driver call a thread is
+// parked in (NtWaitForSingleObject, NtUser*, ...) without symbol files.
+__declspec(noinline) bool nearestExport(const uint8_t* base, uintptr_t rva, char* name, size_t size, uintptr_t* offset) {
+ __try {
+ const auto* dos = reinterpret_cast<const IMAGE_DOS_HEADER*>(base);
+ if (dos->e_magic != IMAGE_DOS_SIGNATURE) return false;
+ const auto* nt = reinterpret_cast<const IMAGE_NT_HEADERS*>(base + dos->e_lfanew);
+ if (nt->Signature != IMAGE_NT_SIGNATURE) return false;
+ const auto& directory = nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];
+ if (!directory.VirtualAddress || !directory.Size) return false;
+ const auto* exports = reinterpret_cast<const IMAGE_EXPORT_DIRECTORY*>(base + directory.VirtualAddress);
+ const auto* functions = reinterpret_cast<const DWORD*>(base + exports->AddressOfFunctions);
+ const auto* names = reinterpret_cast<const DWORD*>(base + exports->AddressOfNames);
+ const auto* ordinals = reinterpret_cast<const WORD*>(base + exports->AddressOfNameOrdinals);
+ DWORD best = 0, bestName = 0;
+ for (DWORD i = 0; i < exports->NumberOfNames; ++i) {
+ const DWORD function = functions[ordinals[i]];
+ const bool forwarded = function >= directory.VirtualAddress && function < directory.VirtualAddress + directory.Size;
+ if (!forwarded && function <= rva && function > best) { best = function; bestName = names[i]; }
+ }
+ if (!bestName || rva - best > 0x10000) return false;
+ strncpy_s(name, size, reinterpret_cast<const char*>(base + bestName), _TRUNCATE);
+ *offset = rva - best;
+ return true;
+ } __except (EXCEPTION_EXECUTE_HANDLER) { return false; }
+}
+
+std::string describe(uintptr_t pc) {
+ HMODULE module = nullptr;
+ if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+ reinterpret_cast<LPCWSTR>(pc), &module) || !module)
+ return std::format("module=? address=0x{:X}", pc);
+ wchar_t path[MAX_PATH]{};
+ GetModuleFileNameW(module, path, MAX_PATH);
+ const uintptr_t rva = pc - reinterpret_cast<uintptr_t>(module);
+ std::string text = std::format("module={} rva=0x{:X}", std::filesystem::path(path).filename().string(), rva);
+ char name[128]{}; uintptr_t offset = 0;
+ if (nearestExport(reinterpret_cast<const uint8_t*>(module), rva, name, sizeof(name), &offset))
+ text += std::format(" near={}+0x{:X}", name, offset);
+ return text;
+}
+
+void logStack(const char* label, const StackSample& sample) {
+ for (unsigned i = 0; i < sample.count; ++i)
+ log::error("engine-hang", std::format("{} frame={} {}", label, i, describe(sample.pc[i])));
+}
+
+void writeDump() {
+ std::wstring directory;
+ { std::lock_guard lock(g_dumpMutex); directory = g_dumpDirectory; }
+ if (directory.empty() || g_dumpsWritten.fetch_add(1) != 0) return;
+ using WriteDump = BOOL(WINAPI*)(HANDLE, DWORD, HANDLE, MINIDUMP_TYPE, PMINIDUMP_EXCEPTION_INFORMATION,
+ PMINIDUMP_USER_STREAM_INFORMATION, PMINIDUMP_CALLBACK_INFORMATION);
+ const HMODULE dbghelp = LoadLibraryExW(L"dbghelp.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
+ const auto write = dbghelp ? reinterpret_cast<WriteDump>(GetProcAddress(dbghelp, "MiniDumpWriteDump")) : nullptr;
+ if (!write) { log::error("engine-hang", "minidump unavailable (dbghelp)"); return; }
+ SYSTEMTIME st{};
+ GetLocalTime(&st);
+ const auto name = std::format(L"veyra-hang-{:04}{:02}{:02}-{:02}{:02}{:02}-{}.dmp", st.wYear, st.wMonth, st.wDay,
+ st.wHour, st.wMinute, st.wSecond, GetCurrentProcessId());
+ const auto path = std::filesystem::path(directory) / name;
+ const HANDLE file = CreateFileW(path.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
+ if (file == INVALID_HANDLE_VALUE) { log::error("engine-hang", std::format("minidump open failed error={}", GetLastError())); return; }
+ // Thread stacks, module list and handle table (which event/mutex a wait is
+ // on); no heap, so the file stays small enough to send with the logs.
+ const auto type = MINIDUMP_TYPE(MiniDumpWithThreadInfo | MiniDumpWithHandleData | MiniDumpWithUnloadedModules);
+ const BOOL ok = write(GetCurrentProcess(), GetCurrentProcessId(), file, type, nullptr, nullptr, nullptr);
+ LARGE_INTEGER bytes{};
+ GetFileSizeEx(file, &bytes);
+ CloseHandle(file);
+ log::error("engine-hang", std::format("minidump written={} file={} bytes={}", ok != FALSE, path.filename().string(), bytes.QuadPart));
+}
+} // namespace
+
+struct EngineWatchdog::State {
+ Notify notify;
+ std::atomic<uint64_t> lastBeat{0};
+ std::atomic<bool> armed{false}, reporting{false};
+ std::atomic<const char*> stage{nullptr};
+ std::atomic<DWORD> ownerId{0};
+ std::mutex mutex;
+ std::condition_variable wake;
+ bool stopping = false, exited = false; // mutex
+ HANDLE owner = nullptr; // mutex
+ std::mutex notifyMutex; // held while the callback runs
+ ~State() { if (owner) CloseHandle(owner); }
+
+ void tell(uint64_t stalledMs) {
+ std::lock_guard lock(notifyMutex);
+ if (notify) notify(stalledMs);
+ }
+
+ HANDLE duplicateOwner(DWORD& id) {
+ std::lock_guard lock(mutex);
+ id = ownerId.load();
+ HANDLE copy = nullptr;
+ if (owner) DuplicateHandle(GetCurrentProcess(), owner, GetCurrentProcess(), &copy, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ return copy;
+ }
+
+ void watch() {
+ uint64_t beatAtReport = 0, resampleAt = 0, notifiedAt = 0, cpuAtReport = 0;
+ unsigned samples = 0;
+ StackSample first{};
+ for (;;) {
+ {
+ std::unique_lock lock(mutex);
+ if (wake.wait_for(lock, std::chrono::milliseconds(250), [&] { return stopping; })) break;
+ }
+ const uint64_t now = GetTickCount64();
+ const uint64_t beatAt = lastBeat.load();
+ const uint64_t stalled = now > beatAt ? now - beatAt : 0;
+ const bool active = armed.load();
+ if (reporting.load()) {
+ if (!active || beatAt != beatAtReport) {
+ log::warn("engine-hang", std::format("owner {} after {} ms (stage={})", active ? "moved again" : "left the playback loop",
+ (active ? beatAt : now) - beatAtReport, stage.load() ? stage.load() : "none"));
+ reporting = false;
+ tell(0);
+ continue;
+ }
+ if (now - notifiedAt >= 1000) { tell(stalled); notifiedAt = now; }
+ if (samples < 3 && now >= resampleAt) {
+ DWORD id = 0;
+ const HANDLE thread = duplicateOwner(id);
+ StackSample again{};
+ if (thread && sampleThread(thread, again)) {
+ const bool same = again.count == first.count && std::memcmp(again.pc, first.pc, sizeof(uintptr_t) * first.count) == 0;
+ log::error("engine-hang", std::format("resample owner={} stalledMs={} cpuMsSinceReport={} stack={}", id, stalled,
+ threadCpuMs(thread) - cpuAtReport, same ? "unchanged" : "changed"));
+ if (!same) logStack("resample", again);
+ Logger::instance().flush();
+ }
+ if (thread) CloseHandle(thread);
+ ++samples;
+ resampleAt = now + 20000;
+ }
+ continue;
+ }
+ if (!active || stalled < kReportMs) continue;
+ reporting = true;
+ beatAtReport = beatAt;
+ DWORD id = 0;
+ const HANDLE thread = duplicateOwner(id);
+ first.count = 0;
+ const bool sampled = thread && sampleThread(thread, first);
+ cpuAtReport = thread ? threadCpuMs(thread) : 0;
+ log::error("engine-hang", std::format("owner={} stalledMs={} lastStage={} cpuMs={} stackFrames={} nvidiaOverlay={} rtss={} gamePP={} (playback loop made no progress; capture/audio threads are separate)",
+ id, stalled, stage.load() ? stage.load() : "none", cpuAtReport, sampled ? first.count : 0,
+ gfx::nvidiaOverlayRunning(), gfx::rivaTunerRunning(), gfx::gamePPRunning() || gfx::gamePPInjected()));
+ if (sampled) logStack("stack", first);
+ if (thread) CloseHandle(thread);
+ Logger::instance().flush();
+ writeDump();
+ Logger::instance().flush();
+ samples = 1;
+ resampleAt = now + 10000;
+ tell(stalled);
+ notifiedAt = now;
+ }
+ std::lock_guard lock(mutex);
+ exited = true;
+ wake.notify_all();
+ }
+};
+
+EngineWatchdog::EngineWatchdog(Notify notify) : state_(std::make_shared<State>()) {
+ state_->notify = std::move(notify);
+ std::thread([state = state_] { state->watch(); }).detach();
+}
+
+EngineWatchdog::~EngineWatchdog() {
+ { std::lock_guard lock(state_->notifyMutex); state_->notify = nullptr; }
+ std::unique_lock lock(state_->mutex);
+ state_->stopping = true;
+ state_->wake.notify_all();
+ // A dump in progress may take a moment; never hold shutdown on it (the
+ // detached thread keeps its own reference to the state).
+ state_->wake.wait_for(lock, std::chrono::seconds(2), [&] { return state_->exited; });
+}
+
+void EngineWatchdog::beat() {
+ auto& s = *state_;
+ const DWORD id = GetCurrentThreadId();
+ if (s.ownerId.load(std::memory_order_relaxed) != id) {
+ std::lock_guard lock(s.mutex);
+ if (s.owner) CloseHandle(s.owner);
+ s.owner = OpenThread(THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_QUERY_LIMITED_INFORMATION, FALSE, id);
+ s.ownerId = id;
+ }
+ s.lastBeat.store(GetTickCount64(), std::memory_order_relaxed);
+ s.armed.store(true, std::memory_order_release);
+}
+
+void EngineWatchdog::disarm() { state_->armed.store(false, std::memory_order_release); }
+std::atomic<const char*>* EngineWatchdog::stage() { return &state_->stage; }
+bool EngineWatchdog::hung() const { return state_->reporting.load(); }
+
+void EngineWatchdog::setDumpDirectory(const std::wstring& directory) {
+ std::lock_guard lock(g_dumpMutex);
+ g_dumpDirectory = directory;
+}
+}
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index ff2f9408..a1338213 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -1219,6 +1219,7 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
const bool wasRunning = impl_->snapshot.running;
const bool wasImage = impl_->snapshot.image;
const bool wasFailed = impl_->snapshot.failed;
+ const bool wasEngineHung = impl_->snapshot.status == engine::kEngineHangStatus;
const bool wasFullscreenUnsafe = impl_->snapshot.vramFullscreenUnsafe;
const auto wasTransport = impl_->snapshot.transport;
const uint64_t wasSession = impl_->snapshot.sessionId;
@@ -1316,6 +1317,8 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
emit notice(text, true);
if (impl_->currentPage == QLatin1String("min")) emit navigate(QStringLiteral("home"));
}
+ // Engine watchdog (field logs(15)): a frozen picture says why, once.
+ if (had && !wasEngineHung && s.status == engine::kEngineHangStatus) emit notice(uiText(s.status), true);
emit snapshotChanged();
}
// An export in flight needs its own poll; it is a separate job and its
@@ -1369,7 +1372,30 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
const bool automatic = impl_->prefString("overlayCompat") != QLatin1String("off");
veyra::log::warn("overlay-hooks", std::format("RivaTuner injected into a run with a GPU interface; its OSD is off in this process ({})",
automatic ? "active OSD server: compatibility restart suggested" : "monitoring compatibility off"));
- if (automatic) emit overlayRestartSuggested();
+ if (automatic) emit overlayRestartSuggested(QStringLiteral("rtss"));
+ }
+ // NVIDIA's in-game overlay switched on after a start with the interface on the GPU
+ // (main.cpp checks at start). Unlike RTSS it cannot be kept out of this process,
+ // and with both swapchains hooked the video and interface threads deadlocked in
+ // the field (gfx/PresentationHooks.h); a restart draws the interface in software.
+ static bool nvidiaOverlayLate = false;
+ if (!nvidiaOverlayLate && !qApp->property("veyraSoftwareUi").toBool() && !qApp->property("veyraUiRendererForced").toBool()
+ && !GetEnvironmentVariableW(L"VEYRA_TEST_IGNORE_NVIDIA_OVERLAY", nullptr, 0) && gfx::nvidiaOverlayRunning()) {
+ nvidiaOverlayLate = true;
+ const bool automatic = impl_->prefString("overlayCompat") != QLatin1String("off");
+ veyra::log::warn("overlay-hooks", std::format("NVIDIA overlay is on in a run with a GPU interface ({})",
+ automatic ? "compatibility restart suggested" : "monitoring compatibility off"));
+ if (automatic) emit overlayRestartSuggested(QStringLiteral("nvidia"));
+ }
+ // GamePP (游戏加加) started after Veyra or injected into it: same as NVIDIA's overlay.
+ static bool gamePPLate = false;
+ if (!gamePPLate && !qApp->property("veyraSoftwareUi").toBool() && !qApp->property("veyraUiRendererForced").toBool()
+ && !GetEnvironmentVariableW(L"VEYRA_TEST_IGNORE_GAMEPP", nullptr, 0) && (gfx::gamePPInjected() || gfx::gamePPRunning())) {
+ gamePPLate = true;
+ const bool automatic = impl_->prefString("overlayCompat") != QLatin1String("off");
+ veyra::log::warn("overlay-hooks", std::format("GamePP is running or injected in a run with a GPU interface ({})",
+ automatic ? "compatibility restart suggested" : "monitoring compatibility off"));
+ if (automatic) emit overlayRestartSuggested(QStringLiteral("gamepp"));
}
// RivaTuner's default hooking keeps OBS game capture from hooking any Direct3D 12
// program (2026-10-03, RTSS 7.3.5.28314 + OBS 32.1.2, a bare D3D12 window included;
@@ -5330,6 +5356,9 @@ void QmlPlayerBridge::resetShortcuts() {
bool QmlPlayerBridge::obsGameCaptureActive() const { return qApp && qApp->property("veyraObsGameCapture").toBool(); }
bool QmlPlayerBridge::overlayCompatActive() const { return qApp && qApp->property("veyraOverlayCompat").toBool(); }
bool QmlPlayerBridge::rivaTunerRunning() const { return gfx::rivaTunerRunning(); }
+bool QmlPlayerBridge::presentationOverlayRunning() const {
+ return gfx::rivaTunerRunning() || gfx::nvidiaOverlayRunning() || gfx::gamePPRunning();
+}
int QmlPlayerBridge::uiScaleActive() const { return qApp ? qApp->property("veyraUiScale").toInt() : 0; }
void QmlPlayerBridge::openFeedbackPage() {