Repository navigation
fix(driver): preserve and reuse observatory URL across app activation and launch - #945
Conversation
…restarting localServer
| // @ts-expect-error this exist in xcuitestdriver or uia2 driver | ||
| await this.proxydriver?.activateApp(appId); | ||
| await reConnectFlutterDriver.bind(this)(this.internalCaps); | ||
| await this.clearNewCommandTimeout(); |
There was a problem hiding this comment.
Could we leave new-command timeout management to BaseDriver.executeCommand here? For the regular activateApp command in the FLUTTER context, FlutterDriver.executeCommand delegates to super.executeCommand, which already clears the timeout before invoking this method and restarts it in its finally block after the awaited reconnect finishes. The additional clearNewCommandTimeout() and try/finally with startNewCommandTimeout() here therefore duplicate that handling.
Please keep the reconnectAfterAppLaunch(...) call itself. The timeout wrapper in the mobile: activateApp / mobile: launchApp branch should also remain, since that branch bypasses super.executeCommand. A timeout test through executeCommand would exercise the normal command lifecycle; the current test calls activateApp directly.
There was a problem hiding this comment.
Updated activateApp to rely on BaseDriver.executeCommand for newCommandTimeout handling while keeping reconnectAfterAppLaunch(...) and the timeout wrapper on mobile: activateApp / mobile: launchApp, and updated the test to run activateApp through executeCommand. Thanks @KazuCocoa!
Previously,
reConnectFlutterDriverclearedLogMonitor.lastMatchinsidegetObservatoryWsUriafteractivateAppormobile: activateApp/mobile: launchApphad already finished. This caused two issues:waitForLastMatchExistchecked for it.activateAppormobile: activateAppbrought an already-running backgrounded app back to the foreground, no new observatory log line was emitted, so clearinglastMatchcausedwaitForLastMatchExistto time out after 10 retries.This change clears
LogMonitor.lastMatchbefore invoking the proxy launch/activation command so log entries emitted during launch are retained, and when activating an app that produces no new log line, tries reconnecting against the previous observatory match first before falling back to waiting for a new log entry. It also pauses and resumesnewCommandTimeoutindriver.activateApp(appId)to matchmobile: activateApp.Fixes #810