Skip to content

[Bug]: Android 3D view stretches the frame when a hinge-capable emulator isn't on its fold inner display #28712

Open

Description

@bramtechs

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Open the Device panel on an Android emulator that has a hinge sensor but is not showing a foldable inner display. For example, the Resizable_Experimental AVD in its Phone mode (1080×2400).
  2. Switch to the 3D view (cube button in the controls rail).

Expected behavior

The 3D model keeps the frame's real aspect ratio. Either the regular Android phone model is used, or the frame is letterboxed inside the fold model.

Actual behavior

The foldable model is shown with a nearly square inner screen, and the phone-shaped frame is stretched across it. Text and UI come out about 2× too wide.

Foldable 3D view stretched

Cause

Having a hinge is taken to mean that the frame is a fold inner display:

  • apps/web/src/components/device/deviceHubAtoms.ts sets a fold angle whenever /vendor/serve-emu/api/fold returns supported: true.
  • packages/client-runtime/src/device/phoneViewer.ts (around lines 110–122) builds createAndroidFoldScene whenever an Android device has a fold angle, whatever the frame's aspect ratio. foldAspect is the frame's aspect only when isFoldInnerAspect (0.75–1.5) holds. Otherwise it falls back to DEFAULT_FOLD_INNER_ASPECT (2076/2152 ≈ 0.96).
  • packages/client-runtime/src/device/androidFoldScene.ts sizes the panel from that aspect (halfWidth = innerAspect * screenHeight / 2 + INSET). It maps the whole texture edge to edge (UVs 0..1 in the screen-geometry loop and in setDisplay for the cover screen), so any mismatch shows up as stretching.

A 1080×2400 frame (0.45) drawn on a 0.96 panel is stretched about 2.1× horizontally. Tablet mode (1920×1200 = 1.6) also falls outside the range and gets the default panel.

A related problem is in updateLayout: innerChanged = isFoldInnerAspect(frameAspect) && frameAspect !== foldAspect. When the frame leaves the fold range, for example when the resizable emulator switches from Foldable to Phone, the fold scene is neither rebuilt nor replaced and keeps the old aspect.

The same assumption applies to real foldables that are showing their cover display while reporting a hinge. The cover screen is also sized from halfWidth, not from the frame.

Possible fix

  • Use the fold scene only while the frame aspect is fold-like. Otherwise fall back to createPhoneScene, and switch between the two in updateLayout when the frame crosses the range.
  • Or keep the fold scene and fit or letterbox the texture to the frame aspect in the inner and cover screen UVs.
  • Regression test: in phoneViewer.test.ts, set a fold angle and a 1080×2400 source, then assert that the phone scene is used or that the screen aspect stays 0.45.

Impact

Minor bug or occasional failure

Version or commit

0.1.6-nightly.20261031.3956 (code checked at main d92c437; phoneViewer.ts and androidFoldScene.ts are unchanged on main since #19559)

Environment

Web client on Windows 11; Android Resizable_Experimental emulator on a device host

Workaround

Switch the resizable emulator to Foldable mode, or use the 2D view.


Written by Claude Code (Claude Opus 5.5) at the reporter's request.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions