Skip to content

fix(mumu): resolve MuMu 12 multi-display foreground app and instance detection (#4) - #5

Merged
Exmeaning merged 3 commits into
masterfrom
arena/c107893b-clickzen
Nov 8, 2026
Merged

Exmeaning merged 3 commits into
masterfrom
arena/c107893b-clickzen

Conversation

@Exmeaning

Copy link
Copy Markdown
Owner

Fixes #4

Root Causes (MuMu 12 v5.x / v6.x, e.g. 6.4.6.0 on 127.0.0.1:16416)

  1. Multi-display virtual screen (app_keptlive / game tab mode)

    • When MuMu 12's background keep-alive or multi-tab mode is enabled, games launch on a secondary Android virtual display (e.g. displayId=2, portrait 761x1376) while displayId=0 remains on app.lawnchair/.LawnchairLauncher with mCurrentFocus=null.
    • scrcpy, adb input, screencap, rotation resolution, and wm size previously targeted only primary displayId=0, showing the empty launcher instead of the active game.
  2. MuMu instance & window discovery (-v <index>, elevated MuMuVMMSVC, relocated VMs, helper windows)

    • MuMuNxDevice.exe passes numeric -v 1 / --vmindex 1 on its command line, while MuMuVMMHeadless.exe runs under the SYSTEM service MuMuVMMSVC (unreadable CLI from an un-elevated process).
    • Previously DetectMuMu fell back to FirstMuMuVm(install, 0), returning null whenever instance 0 had been deleted or was not the running instance (leaving the emulator / window binding list empty).

Changes (modeled on MaaFramework / MAA)

  • Active Display & Foreground App Resolution (DisplayFocusParser, MuMuExternalRenderer)
    • Parse dumpsys window starting at WINDOW MANAGER DISPLAY CONTENTS (ignoring stale LAST ANR blocks) to resolve per-display mCurrentFocus, mFocusedApp, resolution, DPI, and mTopFocusedDisplayId, prioritizing non-launcher foreground apps over launcher/system windows.
    • Optional dynamic bridge to MuMu's official external_renderer_ipc.dll (nx_device/{15.0,12.0}/shell/sdk/external_renderer_ipc.dll) via nemu_connect / nemu_get_display_id / nemu_capture_display for multi-tab tie-breaking and secondary-display capture fallback.
  • Live Display Switching & Multi-Display Input (ScrcpySession, AdbInputInjector, AdbService, DeviceHub)
    • Pass display_id=<id> to scrcpy-server 4.1 and add in-place ScrcpySession.SwitchDisplay(int) with automatic fallback to displayId=0 when a game tab closes.
    • Route adb input (tap, swipe, motionevent, keyevent, text) with -d <displayId> on Android 10+ (SDK >= 29), resolve per-display rotation, validate screencap -d <id> PNG headers, and monitor active display/foreground app in DeviceHub.
  • MuMu 5.x/6.x Detection & Window Binding (EmulatorCatalog, EmulatorConfigParsers, EmulatorDetector, WindowEnumerator, BindWindowDialog)
    • Support -v <N> / --vmindex <N> / --index <N>, MAA's full port/index formulas (16384 + (i % 32) * 32 + (i / 32) * 4 and inverse MuMuPortToIndex), MuMuManager.exe info/adb --vmindex all fallback (with main_wnd HWND matching), auxiliary Qt popup filtering (HintWnd, MessageWnd, *ToolSaveBits), and enriched window-binding / device / mirror / MCP (get_foreground_app) diagnostics.

Exmeaning and others added 3 commits November 8, 2026 08:26
…detection (#4)

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…in DeviceHub

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@Exmeaning
Exmeaning merged commit 7706c80 into master Nov 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

连接mumu模拟器无法获取前台应用

1 participant