Repository navigation
fix(harmony): align observation size with the captured viewport - #3408
Conversation
|
Hi @jiezhnust — thanks for the well-scoped HarmonyOS foldable fix and for adding the regression coverage! Before we can run CI and review it, could you please sign the Contributor License Agreement via the link the CLA assistant posted above? Once it shows as signed, we'll trigger the workflows and take a closer look. The rest looks good from our side (lint/build/tests pass, no public API change). |
quanru
left a comment
There was a problem hiding this comment.
Reading dimensions from the captured JPEG fixes the first-observation viewport mismatch. I found a regression in the standalone Playground preview that needs a change before merge.
- Playground requests
/interface-info, which callsdevice.size()and saves frame A. - The user unfolds the device or the app redraws without an HDC command.
- Playground requests
/screenshot. It receives frame A with a fresh timestamp.
I simulated two distinguishable frames. The same test returned the expanded frame on the base commit and the folded frame on this head. All 133 tests in device.test.ts passed separately.
Could you scope frame reuse to a single observation, keep standalone screenshots fresh, and add this sequence as a regression test? The separate size and screenshot HTTP requests have no shared observation lifetime.
quanru
left a comment
There was a problem hiding this comment.
Verified that the expanded viewport and its screenshot are paired in one observation. The separate Playground screenshot request now returns the expanded frame on the HarmonyOS foldable emulator. The previous stale-frame finding is resolved.
Problem
On HarmonyOS foldables,
RenderServicecan report the physical panel size whilesnapshot_displaycaptures the active viewport.commonContextParsercallssize()beforescreenshotBase64(), so updating the size cache during screenshot capture happens too late for the current observation. The first observation, or the first one after folding/rotation, can therefore use an incorrect screenshot-to-device coordinate ratio.For example, a cached panel size of 2232 x 3184 with an active screenshot of 1008 x 2232 gives an incorrect horizontal ratio of 1008 / 2232; a screenshot x-coordinate of 934 maps to approximately 2068 instead of 934.
Change
size(), derive dimensions from the image, and reuse that exact capture for the followingscreenshotBase64()call.getScreenSize()so repeated flings do not introduce a screenshot per iteration.No public signatures change. A normal size/screenshot observation still captures only once.
Validation
pnpm run lint— passed.pnpm exec nx build @midscene/harmony --output-style=static— passed.pnpm --filter @midscene/harmony exec rstest tests/unit-test/device.test.ts— 133 passed.pnpm exec nx test @midscene/harmony --output-style=static— 308 passed (after building the report template required by existing agent tests).Validation uses mocked device data; no real-device operations or model requests were run for this PR.