Skip to content

[Bug]: Constantly activating hidden RemoteApp or Remote Desktop window that take over the active app focus. #13190

Open

Description

@misakieku

Operating system

Windows

Orca version

1.4.176

Details

Short summary:
Constantly activating hidden RemoteApp or Remote Desktop window that take over the active app focus.

How to reproduce it:

  1. Open Orca.
  2. Maybe you need to pair a mobile device.
  3. Run powershell script
  4. See active window changes.

Script:

Add-Type -AssemblyName System.Windows.Forms

$Code = @"
using System;
using System.Runtime.InteropServices;
using System.Text;

public class WindowTracker {
    public delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime);

    [DllImport("user32.dll")]
    public static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, uint dwFlags);

    [DllImport("user32.dll")]
    public static extern bool UnhookWinEvent(IntPtr hWinEventHook);

    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);

    [DllImport("user32.dll", SetLastError = true)]
    public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

    public const uint EVENT_SYSTEM_FOREGROUND = 0x0003;
    public const uint WINEVENT_OUTOFCONTEXT = 0x0000;
}
"@

Add-Type -TypeDefinition $Code

# Store in $script scope to prevent Garbage Collection
$script:delegate = [WindowTracker+WinEventDelegate]{
    param($hWinEventHook, $eventType, $hwnd, $idObject, $idChild, $dwEventThread, $dwmsEventTime)
    
    if ($hwnd -ne [IntPtr]::Zero) {
        $titleBuilder = New-Object System.Text.StringBuilder 256
        [void][WindowTracker]::GetWindowText($hwnd, $titleBuilder, $titleBuilder.Capacity)
        
        $pidOut = 0
        [void][WindowTracker]::GetWindowThreadProcessId($hwnd, [ref]$pidOut)
        
        $pName = try { (Get-Process -Id $pidOut -ErrorAction SilentlyContinue).ProcessName } catch { "Unknown" }
        $title = $titleBuilder.ToString()
        if ([string]::IsNullOrWhiteSpace($title)) { $title = "<No Title>" }
        
        Write-Host ("[{0}] PID: {1} ({2}) | Title: {3}" -f (Get-Date -Format "HH:mm:ss.fff"), $pidOut, $pName, $title)
    }
}

# Register Hook
$hook = [WindowTracker]::SetWinEventHook(
    [WindowTracker]::EVENT_SYSTEM_FOREGROUND,
    [WindowTracker]::EVENT_SYSTEM_FOREGROUND,
    [IntPtr]::Zero,
    $script:delegate,
    0, 0,
    [WindowTracker]::WINEVENT_OUTOFCONTEXT
)

if ($hook -eq [IntPtr]::Zero) {
    Write-Error "Failed to set WinEvent hook."
    return
}

Write-Host "Hook active and message loop running. Press Ctrl+C to stop..." -ForegroundColor Green

# Run message loop to process hook callbacks
try {
    [System.Windows.Forms.Application]::Run()
} finally {
    # Unhook on exit (Ctrl+C)
    [void][WindowTracker]::UnhookWinEvent($hook)
    Write-Host "`nHook successfully removed." -ForegroundColor Yellow
}

Here is what I get:

[21:14:18.395] PID: 28876 (Orca) | Title: Orca
[21:15:07.882] PID: 31208 (msrdc) | Title: Remote Desktop
[21:15:29.807] PID: 28876 (Orca) | Title: Orca
[21:17:08.881] PID: 49860 (msrdc) | Title: Remote Desktop
[21:17:30.062] PID: 28876 (Orca) | Title: Orca

Activity

  1. added theissue type on Aug 8, 2026
  2. AmethystLiang commented on Aug 8, 2026

    @AmethystLiang
    Contributor

    thanks for reporting. looking into it

  3. monkeylight commented on Aug 11, 2026

    @monkeylight

    I can reproduce this on the current stable release and captured a conclusive foreground-window/process trace.

    Environment

    • Windows: 10.0.19045.6456
    • Orca: 1.4.179 (current stable)
    • WSL: 2.7.11.0
    • Linux kernel: 6.18.33.2-2
    • WSLg: 1.0.73.2
    • MSRDC: 1.2.7214

    Symptoms

    While Orca is running, keyboard focus is lost system-wide. This affects browser inputs, WeChat, and Orca itself. The desktop/taskbar also appears to refresh. Closing Orca stops the behavior.

    The interval is not assumed to be exactly one minute, but two consecutive captured occurrences were about 61 seconds apart.

    Foreground-window trace

    14:24:43.344  pid=172732  process=msrdc  class=TscShellContainerClass
                  title=Remote Desktop
                  process started=14:24:42.561
    
    14:24:50.456  foreground returned to Orca
    
    14:25:44.314  pid=119540  process=msrdc  class=TscShellContainerClass
                  title=Remote Desktop
                  process started=14:25:43.992
    
    14:25:53.615  foreground returned to Orca
    

    Each focus-loss event was a newly created msrdc.exe process, not a persistent Remote Desktop window.

    Elevated process-start trace

    A second trace captured the process chain:

    wslservice.exe
      -> wslhost.exe
         -> msrdc.exe /wslg /silent ... "C:\Program Files\WSL\wslg.rdp"
    

    Example:

    14:34:01  wslhost.exe started by wslservice.exe
    14:34:02  msrdc.exe started by wslhost.exe
               args: /wslg /silent ... wslg.rdp
    

    The WSL distribution is normally stopped between occurrences.

    Orca configuration

    This machine is not configured to use WSL as the Orca runtime:

    • Windows terminal shell: PowerShell
    • terminalWindowsWslDistro: null
    • local Windows runtime default: windows-host
    • WSL CLI registry registeredDistros: empty
    • no .wslconfig file was present

    This suggests that a periodic Orca background capability/account/filesystem probe may be starting WSL even though no WSL runtime is selected. WSLg then creates a fresh MSRDC window which receives foreground activation. This is an inference from the process/focus correlation; the initiating WSL/UNC call was too short-lived to capture directly.

    This is distinct from #7703 / #8053: in this reproduction the foreground owner is conclusively msrdc.exe, not conhost.exe from an unhidden PowerShell/WMIC probe.

    A useful fix would be to avoid starting WSL/WSLg for background probes when the selected runtime is Windows host, or ensure that any such probe cannot activate the WSLg Remote Desktop window.

  4. misakieku commented on Aug 14, 2026

    @misakieku
    Author

    I can solve this temporarily by disabling wslg (gui application support) in wsl. I'm not sure if this is an issue with orca or wslg.

  5. Asjan commented on Sep 30, 2026

    @Asjan

    Same problem. Disabling wslg helped me.

  6. FORyc commented on Oct 10, 2026

    @FORyc

    Confirming this on the current release, with the missing half of the chain: the WSL probe that starts the distro is Orca's own WSL CLI registration/inspection, and it runs for distros that are neither registered nor selected as a runtime.

    Environment

    • Windows 11 26200.9457 (x64, zh-CN)
    • Orca 1.4.223 (MSRDC/WSLg path still affected; the first report was on 1.4.176, @monkeylight reproduced on 1.4.179)
    • WSL 3.0.1.0, kernel 6.18.40.1-1, WSLg 1.0.79, MSRDC 1.2.7214
    • Installed distros: podman-net-usermode (default), podman-machine-default
    • Orca is not configured to use WSL: terminalWindowsWslDistro: null, localAccountWslDistro: null, wsl-cli-registrations.json registeredDistros: [], no WSL project or worktree

    1. The foreground owner is a freshly spawned msrdc.exe (as @monkeylight found)

    Full process chain, captured with a 80 ms Win32_Process poll on msrdc.exe:

    C:\Program Files\WSL\msrdc.exe /wslg /silent /v:DC4A26E1-AEBC-46B4-B710-BEF07F6120F6
        /hvsocketserviceid:00000001-FACB-11E6-BD58-64006A7986D3
        /plugin:WSLDVC_PACKAGE
        /wslgsharedmemorypath:WSL\DC4A26E1-AEBC-46B4-B710-BEF07F6120F6\wslg
        "C:\Program Files\WSL\wslg.rdp"
      parent: wslhost.exe --vm-id {dc4a26e1-aebc-46b4-b710-bef07f6120f6} --handle 2068
      parent: wslservice.exe  (C:\Program Files\WSL\wslservice.exe)
      parent: services.exe -> wininit.exe
    

    C:\Program Files\WSL\wslg.rdp is remoteapplicationmode:i:1 + remoteapplicationprogram:s:dummy-entry, i.e. the WSLg RemoteApp host. The window that takes the foreground is invisible, class TscShellContainerClass, title 远程桌面 (Remote Desktop) / RemoteApp.

    2. Foreground steals, correlated with the Orca process lifetime

    WinEvent hook (EVENT_SYSTEM_FOREGROUND) + GetLastInputInfo, so each entry is tagged "user input" vs "programmatic". In one session, msrdc.exe took the foreground 21 times; 13 of them with no user input for 0.4 s – 12.8 s:

    09:11:22.455  程序主动抢占(idle  671ms)  -> msrdc[pid 44940] class=TscShellContainerClass title='远程桌面' 不可见
    09:25:43.903  程序主动抢占(idle  406ms)  -> msrdc[pid 40364] ...
    09:28:59.100  程序主动抢占(idle 1703ms)  -> Orca[pid 50768]        <-- Orca's own activation (separate issue)
    09:29:00.355  程序主动抢占(idle 2953ms)  -> msrdc[pid 48044] ...
    09:30:28.501  程序主动抢占(idle 5625ms)  -> msrdc[pid 34320] ...
    09:30:51.126  程序主动抢占(idle 7703ms)  -> msrdc[pid 50236] ...
    09:31:11.462  程序主动抢占(idle 5328ms)  -> msrdc[pid 36816] ...
    09:31:39.258  程序主动抢占(idle 12843ms) -> msrdc[pid 33272] ...
    09:31:59.651  程序主动抢占(idle 5453ms)  -> msrdc[pid 22204] ...
    09:32:21.896  程序主动抢占(idle 3156ms)  -> msrdc[pid  5340] ...
    09:33:02.769  程序主动抢占(idle 10547ms) -> msrdc[pid 10784] ...
    09:33:23.144  程序主动抢占(idle 5859ms)  -> msrdc[pid 49620] ...
    09:33:44.765  程序主动抢占(idle 9266ms)  -> msrdc[pid 20384] ...
    09:34:26.858  程序主动抢占(idle 1000ms)  -> msrdc[pid 10372] ...
    

    Orca was restarted at 09:28:56; the first msrdc steal is 09:29:00 and the burst ends at 09:34:26. During a burst the period is ~21 s and every occurrence is a brand-new PID (from 09:40:12 to 09:45:23: 16 consecutive new msrdc.exe processes, one every 20–21 s), matching "not a persistent Remote Desktop window".

    3. New evidence: Orca's WSL inspection starts the distro even with no WSL runtime selected

    %APPDATA%\orca\wsl-cli-registrations.json on this machine:

    {
      "schemaVersion": 2,
      "registeredDistros": [],
      "inspectionTimes": {
        "podman-net-usermode":    1791595746388,
        "podman-machine-default": 1790563855318
      },
      "reconciliations": {}
    }

    1791595746388 = 2026-10-10 09:29:06 local — the same second range in which the msrdc burst started (Orca process start: 09:28:56). 1790563855318 = 2026-09-28 10:50. So Orca wrote an inspection timestamp for a distro that is not in registeredDistros and is not used by any project.

    In app.asar (1.4.223) the inspection set is computed from an enumerated distro list, not from the registered ones:

    var eUi=`wsl-cli-registrations.json`, xJ=2, tUi=10080*60*1e3 /* negativeInspectionTtlMs: 7 days */, nUi=64;
    function iUi(){return{schemaVersion:xJ,registeredDistros:[],inspectionTimes:{},reconciliations:{}}}
    async function hUi(e,t,n={}){ ... let s=r.inspectionTimes[t]; return s===void 0||s>a||a-s>=o }
    function gUi(e,t,n={}){ let r=t.filter(e=>e.inspected&&e.distro.trim()); ... records inspectionTimes per distro ... }

    registeredDistros only feeds reconciliations; every enumerated distro is probed on a 7-day negative TTL. That is the step that starts the WSL VM, and WSLg then materialises a new msrdc.exe RemoteApp host per attempt — each one activating its invisible TscShellContainerClass window. This also explains the reporter's observation that the behaviour appears even though the distro is normally stopped.

    4. Minimal reproduction

    With WSLg enabled (no .wslconfig, or guiApplications unset/true):

    # window 1: watch for new msrdc hosts
    while ($true) {
      Get-CimInstance Win32_Process -Filter "Name='msrdc.exe'" |
        ForEach-Object { "{0} pid={1} {2}" -f (Get-Date -f HH:mm:ss.fff), $_.ProcessId, $_.CommandLine }
      Start-Sleep -Milliseconds 80
    }
    :: window 2: one distro start, equivalent to Orca's in-distro CLI probe.
    :: `wsl.exe -l` alone does not trigger it; running anything inside the distro does.
    wsl.exe -d podman-net-usermode -- true

    Result: msrdc.exe /wslg ... appears ~2.2 s later, and then keeps being recreated every ~21 s for as long as the VM lives. Every creation steals the foreground from whatever the user is typing in.

    5. A/B: [wsl2] guiApplications=false removes it completely

    trigger wsl.exe -d podman-net-usermode -- true observation window msrdc.exe created wslhost.exe (VM started)
    before 1× 90 s 1 (after 2.2 s) + 16 more over the next 7 min yes
    after 1× 90 s 0 yes
    after 3× 75 s 0 yes

    After adding to %USERPROFILE%\.wslconfig:

    [wsl2]
    guiApplications=false

    followed by wsl --shutdown. Note that the VM/wslhost.exe still starts, the distro still runs commands, podman 5.3.0 and podman.socket are unaffected — only the WSLg RemoteApp host is gone. This matches @misakieku and @Asjan above; the same workaround is suggested in microsoft/wslg#894 / #895 / #1135 and microsoft/WSL#41418, which are the same msrdc.exe focus theft at the WSL side.

    6. Requested fix

    1. Do not start a distro in order to inspect it. Enumerating (wsl.exe --list --quiet) does not start the VM; only the in-distro CLI probe does. Gate the probe behind "a WSL distro is actually selected as runtime / registered", make it opt-in, or defer it until that distro is first used.
    2. If a probe must run, make sure a failed/retried WSLg startup cannot loop: here one probe turns into one foreground steal every ~21 s for minutes.
    3. Please surface the guiApplications=false workaround in troubleshooting docs/FAQ until this is fixed.
    4. This is distinct from the conhost foreground steal ([Bug]: Orca periodically causes system-wide keyboard focus loss on Windows #7703 / Fix Windows focus stealing from agent foreground-process scan (hide conhost window) #8053) and from Orca's own activation path ([Bug]: Agent browser automation (orca tab create/switch) forcibly steals Windows foreground focus — no setting or flag to disable #16674, [Bug] Why does orca keep popping to foreground on top of every window for no reason #13278) — in this reproduction the foreground owner is always msrdc.exe (WSLg), never conhost.exe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions