Skip to content

Commit ce4d7d6

Browse files
CopilotrmarinhoCopilot
authored
Fix iOS device test random launch failures with improved retry logic and timeouts (#30796)
* Initial plan * Fix iOS device test random launch failures with improved retry logic and timeouts Co-authored-by: rmarinho <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Fix Cake script compilation error: Replace Task.Delay with Thread.Sleep Co-authored-by: rmarinho <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: rmarinho <[email protected]> Co-authored-by: Rui Marinho <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 159153f commit ce4d7d6

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

eng/devices/devices-shared.cake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,13 @@ void RunMacAndiOSTests(
299299
catch (Exception ex)
300300
{
301301
Information($"Test attempt {i} failed: {ex.Message}");
302+
bool isLaunchFailure = IsSimulatorLaunchFailure(ex);
303+
304+
if (isLaunchFailure)
305+
{
306+
Information("Detected simulator launch failure (exit code 4). This may be a transient issue.");
307+
}
308+
302309
if (i == 1)
303310
{
304311
throw;
@@ -313,6 +320,13 @@ void RunMacAndiOSTests(
313320
{
314321
DeleteFile(logFile);
315322
}
323+
324+
// For launch failures, add a small delay to let the simulator settle
325+
if (isLaunchFailure)
326+
{
327+
Information("Adding delay before retry due to launch failure...");
328+
System.Threading.Thread.Sleep(5000); // 5 second delay
329+
}
316330
}
317331
}
318332
}
@@ -376,3 +390,14 @@ string SanitizeTestResultsFilename(string input)
376390

377391
return resultFilename;
378392
}
393+
394+
bool IsSimulatorLaunchFailure(Exception ex)
395+
{
396+
// Check if the exception message contains indicators of simulator launch failures
397+
var message = ex.Message;
398+
return message.Contains("simctl returned exit code 4") ||
399+
message.Contains("HE0042") ||
400+
message.Contains("Could not launch the app") ||
401+
message.Contains("FBSOpenApplicationServiceErrorDomain") ||
402+
message.Contains("Simulator device failed to launch");
403+
}

eng/devices/ios.cake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,11 @@ void ExecuteTests(string project, string device, string resultsDir, string confi
171171
xcode_args = $"--xcode=\"{XCODE_PATH}\" ";
172172
}
173173

174-
Information($"Testing App: {testApp}");
175-
174+
// Use longer launch timeout for CI builds to handle problematic conditions
175+
var launchTimeout = IsCIBuild() ? "00:10:00" : "00:06:00";
176+
Information($"Using launch timeout: {launchTimeout} (CI: {IsCIBuild()})");
176177

178+
Information($"Testing App: {testApp}");
177179

178180
RunMacAndiOSTests(project, device, resultsDir, config, tfm, rid, toolPath, projectPath, (category) =>
179181
{
@@ -188,7 +190,7 @@ void ExecuteTests(string project, string device, string resultsDir, string confi
188190
$"--targets=\"{device}\" " +
189191
$"--output-directory=\"{resultsDir}\" " +
190192
$"--timeout=01:15:00 " +
191-
$"--launch-timeout=00:06:00 " +
193+
$"--launch-timeout={launchTimeout} " +
192194
xcode_args +
193195
$"--verbosity=\"Debug\" " +
194196
$"--set-env=\"TestFilter={category}\" ");

eng/pipelines/common/device-tests-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ steps:
140140
displayName: Execute Test Run
141141
workingDirectory: ${{ parameters.checkoutDirectory }}
142142
condition: and(succeeded(), ne('${{ parameters.buildType }}', 'buildOnly'))
143-
${{ if or(eq(parameters.buildType, 'windows'), eq(parameters.platform, 'android')) }}:
143+
${{ if or(eq(parameters.buildType, 'windows'), eq(parameters.platform, 'android'), eq(parameters.platform, 'ios')) }}:
144144
retryCountOnTaskFailure: 1
145145

146146
##################################################

src/Templates/src/cgmanifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"type": "nuget",
106106
"nuget": {
107107
"name": "Microsoft.WindowsAppSDK",
108-
"version": "1.7.250513003"
108+
"version": "1.7.250606001"
109109
}
110110
}
111111
},

0 commit comments

Comments
 (0)