Skip to content

Commit b3d99ed

Browse files
Prevent pruning of DWM.exe swap chains with address 0x0
Pruning DWM.exe swap chains with address 0x0 caused inconsistent test results because these swap chains are reused by the Desktop Window Manager for desktop composition. Removing them prematurely led to missing or unexpected data during unit and integration tests, especially in scenarios where DWM activity is infrequent. By excluding DWM.exe swap chains with address 0x0 from pruning, we ensure stable and predictable test outcomes.
1 parent d798d5b commit b3d99ed

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

PresentMon/OutputThread.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,27 @@ static void PruneOldSwapChainData(
838838

839839
for (auto& pair : gProcesses) {
840840
auto processInfo = &pair.second;
841+
842+
// Check if this is DWM process
843+
bool isDwmProcess = false;
844+
std::wstring processName = processInfo->mModuleName;
845+
std::transform(processName.begin(), processName.end(), processName.begin(),
846+
[](wchar_t c) { return (wchar_t) ::towlower(c); });
847+
if (processName.find(L"dwm.exe") != std::wstring::npos) {
848+
isDwmProcess = true;
849+
}
850+
841851
for (auto ii = processInfo->mSwapChain.begin(), ie = processInfo->mSwapChain.end(); ii != ie; ) {
852+
auto swapChainAddress = ii->first;
842853
auto chain = &ii->second;
843-
if (chain->mLastPresent && chain->mLastPresent->PresentStartTime < minTimestamp) {
854+
855+
// Don't prune DWM swap chains with address 0x0
856+
bool shouldSkipPruning = isDwmProcess && swapChainAddress == 0x0;
857+
858+
if (!shouldSkipPruning && chain->mLastPresent && chain->mLastPresent->PresentStartTime < minTimestamp) {
844859
ii = processInfo->mSwapChain.erase(ii);
845-
} else {
860+
}
861+
else {
846862
++ii;
847863
}
848864
}

0 commit comments

Comments
 (0)