Skip to content

Seemingly random 'process crashed' for the instrumentation runner #352

@tsaulic

Description

@tsaulic

Description

What appears to randomly process crashes of the test runner. I understand this may not be the best example on how to present the issue (without the full code), but I was unable to reproduce this on a fresh project :(

Steps to Reproduce

In our app, the test is really simple. When I run it from the IDE it runs almost 100% correctly, from command line via
./gradlew connectedProductionDebugAndroidTest -i

it often fails with the error provided below.

class MyTest {

    private val mockViewModel = mockk<FeedViewModel>(relaxed = true, relaxUnitFun = true)

    @get:Rule
    val mockInjectionRule = MockInjectionRule {
        every { it.myViewModel() } returns mockViewModel
        every { mockViewModel.shouldDoSomething() } returns false
    }

    @Test
    fun myFragment_titleDisplays() {
        launchFragmentInContainer(themeResId = R.style.AppTheme) { MyFragment() }

        onView(withText(R.string.title))
                .check(ViewAssertions.matches(isDisplayed()))
                .check(matches(withParent(withId(R.id.toolbar))))
        onView(withId(R.id.action_settings))
                .check(matches(isDisplayed()))
    }
}

Expected Results

Tests run/pass

Actual Results

Tests pass on average 7/10 times, when they fail, this is logged in Logcat

        ActivityManager  I  Start proc 23437:com.android.chrome:sandboxed_process0/u0i50 for webview_service Ïd
                            ebug/org.chromium.content.app.SandboxedProcessService0
                         W  Slow operation: 57ms so far, now at startProcess: starting to update pids map
                         W  Slow operation: 57ms so far, now at startProcess: done updating pids map
         dboxed_process  W  Unexpected CPU variant for X86 using defaults: x86
         ercentral.debu  I  Background concurrent copying GC freed 161195(5MB) AllocSpace objects, 5(88KB) LOS objects, 36% free, 10MB/1
                            6MB, paused 1.468ms total 178.354ms
        ActivityManager  W  Slow operation: 70ms so far, now at attachApplicationLocked: after mServices.attachApplicationLocked
 cr_ChildProcessService  I  Creating new ChildProcessService pid=23437
        ActivityManager  I  Process com.examplepackage.debug (pid 23395) has died: fore TOP
                 Zygote  I  Process 23395 exited due to signal (11)
        InputDispatcher  W  channel '81514ff com.examplepackage.debug/androidx.fragment.app.testing.FragmentScenario$EmptyFragmen
                            tActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
                         E  channel '81514ff com.examplepackage.debug/androidx.fragment.app.testing.FragmentScenario$EmptyFragmen
                            tActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
        libprocessgroup  W  kill(-23395, 9) failed: No such process
                         I  Successfully killed process cgroup uid 10097 pid 23395 in 4ms
 cr_ChildProcessService  I  Destroying ChildProcessService pid=23437
          WindowManager  I  WIN DEATH: Window{81514ff u0 com.examplepackage.debug/androidx.fragment.app.testing.FragmentScenario$
                            EmptyFragmentActivity}
                         D  HostConnection::get() New Host Connection established 0xe9c0a840, tid 1973
        InputDispatcher  W  Attempted to unregister already unregistered input channel '81514ff com.examplepackage.debug/androidx
                            .fragment.app.testing.FragmentScenario$EmptyFragmentActivity (server)'
         gralloc_ranchu  D  gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
         dboxed_process  I  System.exit called, status: 0
         AndroidRuntime  I  VM exiting with result code 0, cleanup skipped.
                         D  HostConnection::get() New Host Connection established 0xe9c0a840, tid 1973
         gralloc_ranchu  D  gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
                         D  HostConnection::get() New Host Connection established 0xe9c0a840, tid 1973
         gralloc_ranchu  D  gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
                 Zygote  I  Process 23437 exited cleanly (0)
                         D  HostConnection::get() New Host Connection established 0xe9c0a840, tid 1973
   GnssLocationProvider  I  WakeLock acquired by sendMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvSta
                            tusInfo@453db8e)
         gralloc_ranchu  D  gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
   GnssLocationProvider  I  WakeLock released by handleMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvS
                            tatusInfo@453db8e)
         SurfaceFlinger  W  couldn't log to binary event log: overflow.
        ActivityManager  W  Force removing ActivityRecord{82ebca5 u0 com.examplepackage.debug/androidx.fragment.app.testing.Fragm
                            entScenario$EmptyFragmentActivity t300}: app died, no saved state
                         W  Crash of app com.examplepackage.debug running instrumentation ComponentInfo{com.examplepackage
                            .debug.test/com.examplepackage.myapp.CustomTestRunner}
                         I  Force stopping com.examplepackage.debug appid=10097 user=0: finished inst

                            Process com.android.chrome:sandboxed_process0 (PID: 23437) ended

        ActivityManager  I  Killing 23437:com.android.chrome:sandboxed_process0/u0a97i50 (adj 0): isolated not needed
        libprocessgroup  W  Failed to open process cgroup uid 99050 pid 23437: No such file or directory
--
--
                         E  channel '81514ff com.examplepackage.debug/androidx.fragment.app.testing.FragmentScenario$EmptyFragmen
                            tActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
        libprocessgroup  W  kill(-23395, 9) failed: No such process
                         I  Successfully killed process cgroup uid 10097 pid 23395 in 4ms
 cr_ChildProcessService  I  Destroying ChildProcessService pid=23437
          WindowManager  I  WIN DEATH: Window{81514ff u0 com.examplepackage.debug/androidx.fragment.app.testing.FragmentScenario$
                            EmptyFragmentActivity}

AndroidX Test and Android OS Versions

debugImplementation ("androidx.fragment:fragment-testing:1.1.0-alpha08") {
    exclude group: "androidx.test", module: "core"
}

androidTestImplementation 'androidx.test.ext:junit:1.1.1-beta01'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
androidTestImplementation "androidx.arch.core:core-testing:2.0.0"
androidTestUtil 'androidx.test:orchestrator:1.1.1'

Emulator is API 28 Nexus 5, animations turned off.

Link to a public git repo demonstrating the problem:

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions