Learning center

When device emulation is enough to reproduce a mobile bug

A report from an iPhone user reaches a maintainer at a desktop. Chrome's device mode and Playwright's device profiles can make a desktop browser look like that phone: its viewport, pixel ratio, touch input and user-agent string. They do not change the engine. Decide which kind of mobile bug you have before trusting an emulated reproduction.

What emulation changes, measured#

We loaded a page without a viewport meta tag in Playwright's Chromium with the iPhone 13 device profile and read the page's view of itself:

PropertyValue under emulation
navigator.userAgentStarts Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)
devicePixelRatio3
matchMedia('(pointer: coarse)')true
matchMedia('(hover: none)')true
innerWidth980, the default layout width for a page with no viewport meta tag
typeof navigator.userAgentData"object"

The last row gives it away. User-Agent Client Hints exist in Chromium, not in Safari, so a page reading navigator.userAgentData sees a Chromium browser that claims to be an iPhone. The engine underneath is still Blink. Playwright: Emulation ยท Chrome DevTools: Device mode

Which bugs emulation reproduces#

Bug depends onEmulation reproduces it?
Viewport width and media queriesYes
Device pixel ratio, such as blurry images or 1-pixel bordersYes
Touch versus mouse, hover-only menusMostly: touch events and pointer media queries are emulated
The server sniffing the user-agent stringYes, if the profile's string matches the reporter's
Safari's or WebKit's own behavior: layout, form controls, date parsing, storage limitsNo: the engine is Chromium
The on-screen keyboard resizing the viewportNo
iOS-only behavior: home-screen web apps, the dynamic toolbar, autofillNo
Performance on a phone's CPUApproximately, with CPU throttling

Playwright's WebKit build is closer for engine bugs, but it is not Safari on iOS: it runs on desktop with the desktop build's features. For iOS-specific behavior, use a real device or the iOS Simulator, with Safari's Web Inspector attached from a Mac.

Report what the device actually was#

Ask the reporter for:

  • The device model and OS version, and the browser with its version. On iOS every browser uses WebKit, so "Chrome on iPhone" is WebKit too.
  • innerWidth, innerHeight and devicePixelRatio from the page, if they can open a console or a small debug page.
  • Orientation, and whether the page was opened from the home screen.

Then try emulation first: if it reproduces, the maintainer can work at their desk. If it does not, the bug is likely in a row that emulation does not cover.

This example is fictional. A user on an iPhone reports that the Send button in a chat form is hidden when they start typing. The developer opens Chrome's device mode with an iPhone profile, taps the field, and the button stays visible.

The emulated viewport never shrank, because there is no on-screen keyboard in device mode. On a real iPhone, the keyboard covered the bottom of the layout viewport, where the button was fixed. The developer reproduced it in the iOS Simulator with the software keyboard on, and fixed it using the visual viewport's size. The report now records "real device or Simulator" for keyboard-related bugs.

Questions#

Is "Chrome on iPhone" Chrome or Safari?

On iOS, browsers use Apple's WebKit engine, so engine bugs follow Safari's version. Report the iOS version along with the browser's.

Can I emulate an Android phone accurately?

Closer than an iPhone, because Chrome on Android uses Blink too. Android-only behavior, such as the system keyboard, WebView differences or low memory, still needs a device or an emulator.

Why is innerWidth 980 under emulation?

Without a <meta name="viewport"> tag, mobile browsers lay out the page at a default desktop-like width and scale it down. That is also what the real phone does, so it is part of the reproduction, not an emulation artifact.

Return to reproducing what someone else saw for the other layers a replay needs.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading