@@ -145,6 +145,10 @@ function addSniffer(receiver, methodName, override) {
145
145
}
146
146
147
147
async function waitForLighthouseReady ( ) {
148
+ // Undocking later in the function can cause hiccups when Lighthouse enables device emulation.
149
+ // @ts -expect-error global
150
+ UI . dockController . setDockSide ( 'undocked' ) ;
151
+
148
152
// @ts -expect-error global
149
153
const viewManager = UI . viewManager || ( UI . ViewManager . ViewManager || UI . ViewManager ) . instance ( ) ;
150
154
const views = viewManager . views || viewManager . _views ;
@@ -156,9 +160,6 @@ async function waitForLighthouseReady() {
156
160
const button = panel . contentElement . querySelector ( 'button' ) ;
157
161
if ( button . disabled ) throw new Error ( 'Start button disabled' ) ;
158
162
159
- // @ts -expect-error global
160
- UI . dockController . setDockSide ( 'undocked' ) ;
161
-
162
163
// Give the main target model a moment to be available.
163
164
// Otherwise, 'SDK.TargetManager.TargetManager.instance().mainTarget()' is null.
164
165
// @ts -expect-error global
@@ -183,6 +184,13 @@ async function waitForLighthouseReady() {
183
184
}
184
185
}
185
186
}
187
+
188
+ // Ensure the emulation model is ready before Lighthouse starts by enabling device emulation.
189
+ // @ts -expect-error global
190
+ const { deviceModeView} = Emulation . AdvancedApp . instance ( ) ;
191
+ if ( ! deviceModeView . isDeviceModeOn ( ) ) {
192
+ deviceModeView . toggleDeviceMode ( ) ;
193
+ }
186
194
}
187
195
188
196
async function runLighthouse ( ) {
0 commit comments