From 5294e3b6e1d0523c46a5888ad8a2d76dd1334116 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Jun 2026 21:22:51 +0000 Subject: [PATCH 1/2] Initial plan From 72206a1f441bbebef9cf463b6badec70d858fdce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 29 Jun 2026 21:56:15 +0000 Subject: [PATCH 2/2] Fix flaky DebuggingTest: increase WaitForActivityToStart timeout to 150s The 30-second timeout in ApplicationRunsWithoutDebugger (and other tests) was too short for emulators that can take 100+ seconds to launch an app, especially after SwitchUser(). Move the ActivityStartTimeoutInSeconds=150 constant to DeviceTest base class so it's shared across all device tests, and update DebuggingTest, FastDevTest, and BundleToolNoAbiSplitTests to use this constant instead of the hardcoded 30. Fixes #11810 Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com> --- .../Utilities/DeviceTest.cs | 14 ++++++++++++++ .../Tests/BundleToolNoAbiSplitTests.cs | 2 +- .../Tests/DebuggingTest.cs | 4 ++-- .../MSBuildDeviceIntegration/Tests/FastDevTest.cs | 2 +- .../Tests/InstallAndRunTests.cs | 14 -------------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs index bb4870821b5..e7a4dd5031c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs @@ -20,6 +20,20 @@ public class DeviceTest: BaseTest { public const string GuestUserName = "guest1"; + // When running on CI we often see failures where the test fails to spot the "Displayed:" line + // because time between when we start logging and when the application actually is launched + // by the emulator is longer than the timeout we specify (usually 30s). Use this constant as the + // default timeout for all the activity start monitoring calls, adjust per-test as necessary. + // + // Sometimes emulators, for whatever reason, launch the app after a delay of up to 100s and the + // logcat is filled with time-consuming Java exceptions unrelated to our test. We need to account + // for that. Most of the tests used 30s as the activity start timeout, so let's give the emulator + // up to 2 minutes to gather all its ducks in the row + 30 "standard" seconds for our test app + // to start. + // + // It is recommended that no test waiting for the "Displayed:" message waits shorter than this + public const int ActivityStartTimeoutInSeconds = 150; + protected string DeviceAbi { get; private set; } protected int DeviceSdkVersion { get; private set;} diff --git a/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs b/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs index 3b3b5ee14c2..eecbe937e4d 100644 --- a/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/BundleToolNoAbiSplitTests.cs @@ -183,7 +183,7 @@ public void InstallAndRun () Assert.IsTrue (appBuilder.Install (app), "Install should have succeeded."); RunProjectAndAssert (app, appBuilder); Assert.True ( - WaitForActivityToStart (app.PackageName, "MainActivity", Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), 30), + WaitForActivityToStart (app.PackageName, "MainActivity", Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started." ); } diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index c287a1416c1..5c787f694f8 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -92,7 +92,7 @@ public void ApplicationRunsWithoutDebugger ([Values] bool isRelease, [Values] bo AssertExtractNativeLibs (manifest, extractNativeLibs); RunProjectAndAssert (proj, b); Assert.True (WaitForActivityToStart (proj.PackageName, "MainActivity", - Path.Combine (Root, b.ProjectDirectory, "logcat.log"), 30), "Activity should have started."); + Path.Combine (Root, b.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started."); b.BuildLogFile = "uninstall.log"; Assert.True (b.Uninstall (proj), "Project should have uninstalled."); } @@ -173,7 +173,7 @@ public void ClassLibraryMainLauncherRuns ([Values] bool preloadAssemblies, [Valu Assert.True (appBuilder.Install (app), "app should have installed."); RunProjectAndAssert (app, appBuilder); Assert.True (WaitForActivityToStart (app.PackageName, "MainActivity", - Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), 30), "Activity should have started."); + Path.Combine (Root, appBuilder.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started."); } } diff --git a/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs b/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs index fd543fda9d5..697274e0cb6 100644 --- a/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs @@ -210,7 +210,7 @@ public void FastDevWithEmbeddedDex ([Values (false, true)] bool useEmbeddedDex) ClearAdbLogcat (); RunProjectAndAssert (proj, b); Assert.True (WaitForActivityToStart (proj.PackageName, "MainActivity", - Path.Combine (Root, b.ProjectDirectory, "logcat.log"), 30), "Activity should have started."); + Path.Combine (Root, b.ProjectDirectory, "logcat.log"), ActivityStartTimeoutInSeconds), "Activity should have started."); b.BuildLogFile = "uninstall.log"; Assert.True (b.Uninstall (proj), "Project should have uninstalled."); } diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index dc3e1a83644..241f116a183 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -19,20 +19,6 @@ namespace Xamarin.Android.Build.Tests [Category ("UsesDevice")] public class InstallAndRunTests : DeviceTest { - // When running on CI we often see failures where the test fails to spot the "Displayed:" line - // because time between when we start logging and when the application actually is launched - // by the emulator is longer than the timeout we specify (usually 30s). Use this constant as the - // default timeout for all the activity start monitoring calls, adjust per-test as necessary. - // - // Sometimes emulators, for whatever reason, launch the app after a delay of up to 100s and the - // logcat is filled with time-consuming Java exceptions unrelated to our test. We need to account - // for that. Most of the tests used 30s as the activity start timeout, so let's give the emulator - // up to 2 minutes to gather all its ducks in the row + 30 "standard" seconds for our test app - // to start. - // - // It is recommended that no test waiting for the "Displayed:" message waits shorter than this - public const int ActivityStartTimeoutInSeconds = 150; - static ProjectBuilder builder; static XamarinAndroidApplicationProject proj;