GoogleChrome / GoogleChrome/lighthouse

Lighthouse resets emulation incorrectly after DevTools run

Open
#14,134 7 comments 0 reactions 0 assignees View on GitHub
bug DevTools P2 upstream-action-required
Dominant language
JavaScript
Stars
30.8k
Forks
9.8k
Avg merge
1d 14h
Merged PRs (30d)
20

Description

### FAQ

- [X] Yes, my issue is not about [variability](https://github.com/GoogleChrome/lighthouse/blob/master/docs/variability.md) or [throttling](https://github.com/GoogleChrome/lighthouse/blob/master/docs/throttling.md).
- [X] Yes, my issue is not about a specific accessibility audit (file with [axe-core](https://github.com/dequelabs/axe-core) instead).

### URL

https://1uqxj0.csb.app/

### What happened?

Lighthouse seems to reset the screen width emulation on mobile devices (from `window.screen.width`) after a report is generated. This can affect subsequent reports.

To reproduce:
1. Open the URL on Chrome, using responsive mode change your device to any device with < 600px width (e.g. iPhone SE).
2. Refresh the page -- you should see the page display the text "portrait".
3. Run a Lighthouse report. While the test is running, the page should also display "portrait".
4. Once page refreshes after the report is generated, the page will display "landscape". Refreshing the page will still show "landscape".
5. Any subsequent runs of Lighthouse will also display "landscape" on the screen.

You can reset this by going out of responsive mode and going back in.

### What did you expect?

I expected Lighthouse to maintain the `window.screen` emulation after the first report.

### What have you tried?

Running without Lighthouse works fine -- you can jump in and out of responsive mode without any hitches. Firefox and Safari also work fine.

### How were you running Lighthouse?

Chrome DevTools

### Lighthouse Version

9.5.0

### Chrome Version

102.0.5005.61

### Node Version

_No response_

### OS

MacOS

### Relevant log output

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue at the provided URL in Chrome DevTools responsive mode with a device narrower than 600px, then run a Lighthouse report and observe window.screen.width before and after it. The fix is complete when subsequent reports preserve the original mobile screen-width emulation without requiring responsive mode to be reset.

Written by the indexing model from the issue text.

Assessment

Tech stack
devtools, javascript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.