Skip to content

fix(driver): preserve and reuse observatory URL across app activation and launch - #945

Merged
KazuCocoa merged 3 commits into
appium:mainfrom
hoanle0126:fix/activate-app-observatory-810
Oct 28, 2026
Merged

KazuCocoa merged 3 commits into
appium:mainfrom
hoanle0126:fix/activate-app-observatory-810

Conversation

@hoanle0126

Copy link
Copy Markdown
Contributor

Previously, reConnectFlutterDriver cleared LogMonitor.lastMatch inside getObservatoryWsUri after activateApp or mobile: activateApp / mobile: launchApp had already finished. This caused two issues:

  1. Any new observatory URL logged while the proxy driver was launching the app was cleared before waitForLastMatchExist checked for it.
  2. When activateApp or mobile: activateApp brought an already-running backgrounded app back to the foreground, no new observatory log line was emitted, so clearing lastMatch caused waitForLastMatchExist to time out after 10 retries.

This change clears LogMonitor.lastMatch before 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 resumes newCommandTimeout in driver.activateApp(appId) to match mobile: activateApp.

Fixes #810

Comment thread driver/lib/driver.ts Resolved
Comment thread driver/lib/driver.ts Outdated
// @ts-expect-error this exist in xcuitestdriver or uia2 driver
await this.proxydriver?.activateApp(appId);
await reConnectFlutterDriver.bind(this)(this.internalCaps);
await this.clearNewCommandTimeout();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@KazuCocoa
KazuCocoa merged commit 2fd76f2 into appium:main Oct 28, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Activate app not working properly

2 participants