Skip to content

开机设置做完才报运行中;带窗口开机时盖一层开机画面 - #217

Merged
qiyinxi merged 17 commits into
ModAVD:mainfrom
qiyinxi:feat/boot-ready-259
Nov 28, 2026
Merged

qiyinxi merged 17 commits into
ModAVD:mainfrom
qiyinxi:feat/boot-ready-259

Conversation

@qiyinxi

@qiyinxi qiyinxi commented Nov 28, 2026

Copy link
Copy Markdown
Member

改了什么

Refs ModAVD/ModAVD#259

开机设置做完才算在线(13b)

  • status、MCP 和管理器界面里的「运行中」(online),改成安卓开机完成、并且这次开机的开机后设置也做完以后才报。设置期间仍报 starting,另带当前步骤和百分比。
  • 设置卡住时不会一直停在 starting:安卓开机完成后最多再等 60 秒,到点照报 online,日志写明哪一步没做完。模拟器不是 modavd 起的、上一次 start 中途没了、客体自己重启,这几种情况都有单测。
  • status 的取值没有新增,命令行 start 返回的时刻不变。

带窗口开机时盖一层开机画面(13c,只做 Windows)

  • 带窗口开机时,起一个辅助进程 __bootoverlay,在模拟器窗口上盖一层开机画面:角色抱着的屏幕里的画随进度显出来,下面是进度条、百分比和当前步骤(中英跟管理器语言走)。
  • 这段时间模拟器窗口和旁边的工具栏都点不到,键盘也进不去。设置做完的那一刻把窗口还给用户,遮罩改成鼠标穿透,播约 2 秒完成动画再淡出。
  • 命令行 start --window 也有遮罩;无头开机不起遮罩。管理器网页里看实例画面那页,开机中显示同一张画面。
  • 美术是现有的 ModAVD 角色形象拆层做的,用调色板 PNG 压到约 0.4 MB。

窗口一定会还回来

  • 遮罩跨进程禁用模拟器窗口之前,以下几样都要确认:遮罩自己的身份、qemu 的身份、这一轮开机的记录、这台 qemu 的 __bootwatch 在跑。缺一样就只挡鼠标,不禁用窗口。
  • 禁用过哪些窗口记在标记文件里。遮罩进程没了、start 被取消或失败、管理器退出时,由 __bootwatch 恢复;stop 也会恢复。
  • 遮罩从自己启动起最多 360 秒,到点一定放手。

怎么测的

  • 单测和 go vet 在 Windows 上通过,darwin、linux 能编过。internal/win 的窗口测试要单独跑:和别的包并行时,桌面上别的窗口会盖住测试窗口。
  • 「窗口一定会还回来」那几层守卫,以及完成动画的几个出口,都做了变异检查:删掉或反转判断,都有测试失败。
  • 另外复审过三轮:前两轮全面看,第三轮只核第二轮要改的几条,没有 P0、P1。
  • 真机:在 flow-b 的开发实例上,用这个分支带窗口开机 5 次,用改之前的版本带窗口开机 1 次做对照。无头开机在加固之前的版本上新旧各测过 2 次,加固以后没再测。
    • 状态变 online、遮罩放手、start 返回,三个时刻相差不到 0.6 秒。从安卓开机完成到 start 返回 5.4 秒,和改之前的 5.0–6.7 秒一样。
    • 开机期间模拟器窗口一直是禁用的,工具栏按钮上最上面是遮罩;放手后按钮上立刻是模拟器窗口。
    • modavd window 藏起和显示窗口时,遮罩跟着藏、跟着出来,位置一致。
    • 前台窗口没被抢。
    • 完成动画在 start 返回后照样播完(2.2–2.9 秒)。
    • 带 --launch 打开明日方舟能到标题页;每次都正常关机。
  • 遮罩退出后,模拟器窗口用 PrintWindow 和屏幕截图截出来是灰的。改之前的版本在同样条件下也一样灰,是这两种取法截不到 GPU 显示子窗口,不是这次改动造成的。

已知限制

  • 遮罩上限固定 360 秒,不看调用方给的 --timeout。超时给得更长、开机又慢时,遮罩会先放手。
  • 模拟器的消息循环卡死时,多个恢复调用会各占一个阻塞线程,直到进程退出才回收。
  • 接管一台已经在开机的实例、又要装输入法时,遮罩起来后不等「已挡住输入」确认,就开始装。
  • 恢复进程里最长 6 小时的等待不能取消。confirm 分不清「没禁用」「只显示」「已退出」三种情况。
  • 重启后 2.3 秒内再开机,上一个遮罩还占着锁,这一次不起遮罩。
  • 遮罩空闲时每 80 毫秒重画一次,开机那段时间占约一成的一个核。
  • 没做眨眼:美术里没有闭眼的图。网页里没有完成动画,就绪后直接换成实时画面。
  • 窗口移动、缩放、跨显示器,没在真机上测,只有单测。

status / list / info / MCP report starting (busy starting too) from Android's boot until the
setup of that boot is done, at most 60 s after the start began it; a record in
avd\.mas_<i>.ready (qemu PID + creation time, step, percent) carries it across processes.
New fields setup_step, setup_progress, setup_unfinished. A qemu no start sets up, a start
that was cancelled or killed, and the cap never leave it at starting.

Refs ModAVD/ModAVD#259
…lock probe

The 60 s wait of the after-boot setup counts on the machine's millisecond counter (a deadline fixed once, shared by the readers and the log line), not the wall clock. A start deletes the earlier boot's record before it writes its own; a record that cannot be written is not tracked (warned, status does not wait), and the setup marker's heartbeat bounds the wait before the record exists. A take-over starts a record when it is about to do real work (first-boot setup, installing the host input method). Queries probe the start / stop / boot locks with a shared lock so concurrent queries never take each other for a start; the record names its writer process and the guest boot_id (read only while a record that is not done would hold the instance). Cancelling the /sdcard wait is not a completed setup. The step goes back to tune after the named steps; creating / create_failed clear the setup fields.

Refs ModAVD/ModAVD#259
…nline (Windows)

A windowed start (the command line's and the manager's) starts a small process of the same executable,
`__bootoverlay`, that lays a pop-up owned by the emulator's main window over its picture area and one over the side
toolbar, shows the brand avatar, a progress bar and a line of what is being done, and disables the emulator's windows
(EnableWindow) so the keyboard cannot reach them either. It reads what status reads (the setup record, the start lock,
one getprop), takes the cover away at the moment status says online, and on the cap puts the windows back first and
leaves a note for 3 s. Four layers give the windows back: the overlay restores them before it exits; the start that
started it watches its process every 0.5 s; the overlay ends within 1.5 s of no start holding the lock or the starter
being gone; and a mark on disk (.mas_<i>.overlay) is found by the next status / list / info / start / stop / window.
The manager's screen viewer shows the same picture and the progress while an instance boots.

Refs ModAVD/ModAVD#259
…ate bar, 100 ms looks

The cover follows the layout of the final artwork: a thin coral bar under the character (about 60 % of its width), the
percentage at its right, the step under it, placed from the middle of the window and scaled with min(height / 720,
width / 810) so wide, 4:3 and portrait windows keep it. The bar is the setup's own percentage; before the setup reports
one (launch, Android booting, no record yet) it is indeterminate and the number reads "…". The overlay looks every
100 ms (the windows are back about 0.15 s after the setup is recorded as done). The manager's viewer shows the same
bar, number and step.

Refs ModAVD/ModAVD#259
Windows the overlay disables are state of another process, so everything around them is made to fail safe.

- The windows are named in the overlay's mark (round, overlay, qemu, and per window the handle, owning process, qemu
  creation time and class) before they are disabled; when the mark cannot be written nothing is disabled. Handles are
  checked before every touch and dropped when they are another window now. Marks are read, changed and deleted under a
  lock and only by their own round; an enable that fails on a window that is still there keeps its entry.
- All EnableWindow calls run on a worker (windowKeeper) with a 2 s deadline; the cover's thread never waits for them, and
  lifecycle commands recover in the background with a 1 s budget. The first disable waits for the first look at the
  instance, and a latched end request stops every further disable.
- The cover has no owner (an owner ties its input queue to the emulator window's thread); it follows the window with
  SetWindowPos on itself. At the cap or when ready the covers become mouse-through at once (WS_EX_TRANSPARENT).
- A close of a cover and the end of the session take the same restore path as Quit; Quit is a latch the loop and the timer
  look at, not only a message.
- Round token per start attempt, written into the setup marker / record before the overlay starts; the overlay and status
  only believe a setup record of that round. The start holds a handle to the overlay and the overlay to the start (no
  PID polling); the start confirms the overlay gave the windows back before it returns.
- The boot watch (started with the overlay) gives back the windows of an overlay that is gone within about a second.
- The overlay's poller no longer waits for adb. A take-over with real setup work on a window boot gets the cover too. A
  done record that cannot be written is read as done at once.

Refs ModAVD/ModAVD#259
…ootwatch

It ends by itself when its instance is online or its qemu or start is gone, and gives the emulator's windows back before it
does; its argv (exe, __bootoverlay, root, index, starter pid, starter creation time, round token) is checked like the
watch's, and a different root, a missing or odd round token or an extra argument never grants a wait.

Refs ModAVD/ModAVD#259
…e a window is disabled)

- Nothing is disabled unless the overlay's own process and creation time, the qemu's (published whole as one value), this
  round (its marker or record is there; a round nobody tracks ends within 2 s without disabling anything) and the boot
  watch of exactly this qemu (its info names the qemu and a live process, and it holds the watch lock; waited for up to 3 s,
  then given up on for this run) are known. The mark that is already on disk is read under the lock: an unreadable one is
  not "none" (nothing is disabled), and what an earlier overlay could not give back is carried into the new mark, given
  back at once and never overwritten.
- The window is checked again on the goroutine that makes the EnableWindow call, right before it.
- A start that cannot publish its round (the setup marker cannot be written) starts no overlay.
- The cap also counts from the overlay's own start (DefaultBootTimeout + bootSetupCap), whatever adb says; after Release
  nothing is disabled again; a cover that cannot be made mouse-through is hidden for good.
- The boot watch only looks at marks of its own qemu; a recovery that finds the same windows still not answering does not
  rewrite the mark or warn again.
- Covers: one SetWindowPos does position, size, z-order and visibility without activating anything; the cover is topmost
  exactly when its emulator window is, and under a third party's topmost window it goes to the top of the non-topmost ones
  instead of over it.

Refs ModAVD/ModAVD#259
…ay so when the qemu's identity is not whole

- The keeper remembered "the boot watch is running" for the rest of the run. When the qemu the overlay covers is replaced
  (a takeover whose boot exits and is started again), the overlay would have gone on disabling the new qemu's windows
  before the new qemu's boot watch was up. The guard is now remembered together with the qemu it was found for (PID and
  creation time); another qemu starts the wait (and the give-up time) afresh.
- A qemu whose creation time cannot be read already disabled nothing; it now says so once in the log, like an overlay that
  cannot read its own identity.

Refs ModAVD/ModAVD#259
The exported parts, screen states, eruption frames and sprites were 8-bit RGBA PNGs of 3.26 MB. They are paletted PNGs with
alpha now (octree, 256 colours, no dithering): 394 KB in all, the package's artwork limit being 1 MB. The error against the
originals is about 3 of 255 per channel (premultiplied RMS), and the rendered frames look the same.

Refs ModAVD/ModAVD#259
…e eruption when ready) on the window and in the page

- bootscreen/v3.go reads art/rig.json and draws the 15 parts in z order, each moved a little by its own sine (and its
  group's: the head), the screen filling in with the progress (the two nearest screen states cross-faded), and, when the
  instance is ready, the 15 eruption key frames, the wind on the five hair parts, seven particles outside the screen, then the
  fade (1.66 s to 2.21 s). The parts are scaled once for a frame size and only moved by bilinear sampling afterwards; the
  bitmap is made again only every 80 ms (33 ms in the eruption) or when the progress moves by 1 %. The avatar placeholder is
  gone. The bar, the percentage and the step line stay the code's own (layers.json "progressUi").
- The overlay no longer ends the moment the instance is ready: it gives the windows back and lets the mouse through at once,
  then shows the eruption and "Ready" for 2.3 s, fading the covers by their window opacity (win.Overlay.SetAlpha), and ends.
- The manager's screen viewer draws the same picture on a canvas from the same files, which the page serves at assets/boot/
  (it keeps the bar and the step but has no eruption: the live screen replaces it when the instance is ready).

Refs ModAVD/ModAVD#259
Mutating each guard of the hardening (identity known before a window is disabled, the old mark carried and never overwritten,
the window checked right before EnableWindow, no overlay for a round that could not be published, the cap counted from the
overlay's own start, nothing disabled after Release, the boot watch of exactly this qemu, the cover following the emulator
window's z-order) showed three that no test noticed; they have one now:

- the boot watch only gives back the marks of its own qemu (process and creation time), not another boot's of the same
  instance;
- Release in the middle of a step stops the windows that are not disabled yet from being disabled;
- the keeper waits for the boot watch of a replaced qemu from the start: the time spent on the first one does not count
  against it, and neither does having given up on it.

An unreadable mark that is not a file (a directory) is covered by the failed write that follows it; that guard alone cannot be
told apart by a test.

Refs ModAVD/ModAVD#259
…rned

The overlay's --watch process is the start command, and start returns right after
it lets the windows go, so overlayMachine.Next ended the eruption and fade with
watch-gone (0.2 to 1.0 s after the release) before they were played.

Once the instance is ready (doneAt set) the windows are already back and the cover
is only a picture: the starting process and the start lock no longer end it. Only
the show's own length (capped by overlayDoneCap, 5 s) and the qemu going away do.
Before ready nothing changes: no starter or no start lock still ends it at once.

Refs ModAVD/ModAVD#259
@qiyinxi qiyinxi added the enhancement New feature or request / 新功能或改进 label Nov 28, 2026
@qiyinxi
qiyinxi added this pull request to the merge queue Nov 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 28, 2026
@qiyinxi
qiyinxi added this pull request to the merge queue Nov 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 28, 2026
@qiyinxi
qiyinxi added this pull request to the merge queue Nov 28, 2026
Merged via the queue into ModAVD:main with commit 34dead8 Nov 28, 2026
6 checks passed
qiyinxi added a commit to qiyinxi/ModAVDManager that referenced this pull request Nov 28, 2026
冲突:internal/emu/bootwatch.go 两边各加了一个开机守护的后台循环(脚本专用 server、开机画面标记的恢复),都保留,退出时两个都等;internal/emu/portplan_test.go 两边各加了假 adb 的环境变量,都保留。

Refs ModAVD/ModAVD#291
Refs ModAVD/ModAVD#292
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request / 新功能或改进

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant