Skip to content

Figure out WearOS test failures #7506

@jonpryor

Description

@jonpryor

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

CI

Description

The wearOS on-device unit tests are frequently flaky. Why?

Plausible "shoot from the hip" answers include:

  • Build system bugs
  • Unit test validation bugs
  • Heisenbugs

TypeAndMemberRemapping

Consider b5678d7b13d26f9270e3ce3ab169bd83ee4c2520 + TypeAndMemberRemapping(False):

Activity.onCreate() wasn't remapped to RemapActivity.onMyCreate()!
Expected: String containing "RemapActivity.onMyCreate() invoked!"
But was:  "--------- beginning of main
…

If I download the wearOS build tree, I can extract lib/x86/libxamarin-app.so from bin/Debug/net8.0-android/android-x86/com.xamarin.typeandmemberremapping-Signed.apk, run strings lib/x86/libxamarin-app.so, and verify that libxamarin-app.so does appear to have remapping data:

…
android/app/Activity
example/RemapActivity
setOnClickListener
example/ViewHelper
mySetOnClickListener
onCreate
onMyCreate

Leading me to believe that libxamarin-app.so does contain type map data (yay!).

If I launch a local API-22 emulator, I can "manually" install the app:

adb -e install bin/Debug/net8.0-android/android-x86/com.xamarin.typeandmemberremapping-Signed.apk                                   
adb -e shell am start com.xamarin.typeandmemberremapping/com.xamarin.typeandmemberremapping.MainActivity
adb -e push obj/Debug/net8.0-android/android-x86/android/assets/*.dll /data/data/com.xamarin.typeandmemberremapping/files/.__override__

Then I can collect logcat output, re-launch the app:

adb -e logcat > log-e.txt &
adb -e shell am start com.xamarin.typeandmemberremapping/com.xamarin.typeandmemberremapping.MainActivity

When reading log-e.txt, it does contain:

D/*REMAP-TEST*( 3304): RemapActivity.onMyCreate() invoked!
D/*REMAP-TEST*( 3304): ViewHelper.mySetOnClickListener() invoked!

Thus, why did this test fail? What should change to increase test reliability?

If I look at logcat-Release-full.txt, there is something weird going on:

% grep -E 'RemapA|(Displayed.*typeandmem)' logcat-Release-full.txt
10-27 22:19:52.119   520   620 I ActivityTaskManager: Displayed com.xamarin.typeandmemberremapping/.MainActivity: +2s394ms
10-27 22:21:07.428 13714 13714 D *REMAP-TEST*: RemapActivity.onMyCreate() invoked!
10-27 22:21:10.619   520   620 I ActivityTaskManager: Displayed com.xamarin.typeandmemberremapping/.MainActivity: +4s572ms

We do see the RemapActivity.onMyCreate but why doesn't the test see it? Does it somehow stop parsing at the first Displayed message (which presumably is emitted as part of fast deployment, and thus should be skipped)? Something else?

What is the bug? (Is there a bug?) How do we increase reliability?

DotNet* Failures

Commit 5f3deea2fa3b5d496a0c6ebde94ea48addbdb14d has 7 unit test failures across DotNetInstallAndRun(…) and DotNetDebug(…). I have not investigated this, but why did they fail?

I suspect it's because the emulator is FUBAR, e.g. this screenshot.png attachment shows:

setup isn't responding
❌ Close app
🕓 Wait

That's not an encouraging sign…. Is there a way we can detect this and perhaps restart the emulator?

Steps to Reproduce

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions