Skip to content

fix(wda): a launch right after a reinstall waits for iOS to register the app - #257

Merged
omnarayan merged 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:fix/wda-launch-unregistered-app
Oct 29, 2026
Merged

omnarayan merged 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:fix/wda-launch-unregistered-app

Conversation

@luka-vladika-happening-xyz

Copy link
Copy Markdown
Contributor

Summary

Fixes #251. Right after clearState's reinstall on a real iPhone, iOS may not have registered the app yet, and WDA's launch fails with FrontBoard's NotFound (FBSOpenApplicationErrorDomain Code=4). Both launches the WDA driver makes now send it again every 500 ms for up to 10 s, then fail with the last error.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Changes Made

  • Client.postLaunch posts a launch and sends it again while WDA's error holds FBSOpenApplicationErrorDomain Code=4, every launchRetryEvery (500 ms) until launchRetryFor (10 s) has passed. Then it returns the last error. Any other error returns at once.
  • Both launches go through it:
    • LaunchAppWithArgs: /wda/apps/launch, launchApp when there is a session;
    • CreateSession: a session with a bundleId launches the app. That covers EnsureSession at a flow's start, and launchApp when there is no session yet.
  • A launch that needed a retry logs one line: WDA launch of <bundleId>: iOS had not registered the app yet; launched after 2 tries in 3.03s. A launch that gave up logs … iOS still did not know the app after 21 tries in 10.2s.
  • As you suggested, it applies to every launch, not only after clearState. So an app that is not installed at all now fails after 10 s instead of at once, with the same error.
  • Tests (launch_retry_test.go, a fake WDA):
    • TestLaunchAppWaitsForIOSToRegisterTheApp and TestLaunchAppWithoutSessionWaitsForIOSToRegisterTheApp: three Code=4 answers, then a 200. One goes through launchApp with a session (/wda/apps/launch), the other without one (POST /session). Each uses three wordings: the launch answers of iOS 17 and 26 and of iOS 18, and the session answer of iOS 26 and 27. They also check the one log line;
    • TestLaunchAppGivesUpOnAnAppIOSDoesNotKnow: Code=4 every time, so the launch fails with WDA's error after launchRetryFor;
    • TestLaunchAppDoesNotRetryOtherErrors: any other error is sent once.

Related Issues

Fixes #251

Testing

  • The first three tests fail on main and pass with the change. The fourth passes on both
  • go vet, gofmt -s -l and golangci-lint v2.13.2 (CI's pin, under go1.26.7) report nothing
  • go test -race ./... passes. pkg/driver/browser/cdp and pkg/emulator were left out: they fail on this Mac on main too (Chrome's launch; an emulator holding 5554)
  • On a real iPhone 13 mini (iOS 26.2.1) with its screen streamed (WDA's MJPEG), driven through --wda-url with MAESTRO_RUNNER_IOS_INSTALLER=zipconduit:
    • the issue's flow (15 × launchApp: {clearState: true}): main failed at the second launch with Code=4. With this change, 15 of 15 launched, 11 of them after one retry, 2.8–3.3 s after the first try;
    • a flow whose only step is launchApp: {clearState: true}, 8 runs: all passed, 6 of them after one or two retries of /wda/apps/launch (3.4–4.2 s);
    • the same flow with the app uninstalled before each run, so that the run's session is created after the reinstall, 4 runs: each POST /session right after the reinstall got Code=4, then launched on the second try (3.7–6.0 s).
  • make test as a whole: not run, because its device tests drive whatever device is attached

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added/updated documentation as needed (no CHANGELOG line: you add it when merging)
  • No breaking changes (or documented if breaking)
  • CHANGELOG.md updated (left to you when merging)

Additional Notes

  • When the session is the launch after the reinstall. On main, the flow runner's EnsureSession creates the session when the flow starts, before launchApp reinstalls. So in most runs the launch after the reinstall is /wda/apps/launch. A session comes after the reinstall when EnsureSession failed, because the app was not installed when the flow began. The last set of runs above is that case.
  • The cost for an app that is not installed. The EnsureSession of such a flow now waits 10 s before it gives up, with one warning line. Before, it gave up at once. Its launchApp then installs the app and goes on as before.
  • The wording depends on the path, not only the iOS version. /wda/apps/launch says "… is unknown to FrontBoard" on iOS 17 and 26, and "Unknown application display identifier …" on iOS 18. A new session says "Application info provider (FBSApplicationLibrary) returned nil for …" on iOS 26 and 27. All of them are FBSOpenApplicationErrorDomain Code=4 (NotFound), which is what the retry matches.
  • iOS 27: two phones (27.0.1 and 27.2) launched 14 of 14 each without the race this morning.

…the app

Right after clearState's reinstall on a real iPhone, iOS may not have
registered the app yet, and WDA's launch fails with FrontBoard's NotFound
(FBSOpenApplicationErrorDomain Code=4). Both launches now send it again
every 500 ms for up to 10 s: /wda/apps/launch, and a new session with the
app's bundleId. A launch that needed it logs one line. Any other error,
and the last NotFound after 10 s, fail the launch as before.

Fixes devicelab-dev#251
@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@omnarayan
omnarayan merged commit 0722479 into devicelab-dev:main Oct 29, 2026
5 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.

[BUG] WDA driver: launchApp right after clearState's reinstall fails on real iPhones (FBSOpenApplicationErrorDomain Code=4)

3 participants