Seemingly random 'process crashed' for the instrumentation runner
See original GitHub issueDescription
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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:25
- Comments:29
Top Results From Across the Web
Instrumentation run failed due to 'Process crashed.'
Test running failed: Instrumentation run failed due to 'Process crashed.' In my case, the android test console only showed the error above ...
Read more >Dozens of crashes found with libdislocator, but cannot ...
I am still having this issue - I have crashes on seemingly random files that are only found with libdislocator (ASAN finds nothing,...
Read more >Adventures making gnome-shell run in Valgrind: part 1
My adventures debugging crashes and hangs when running gnome-shell in Valgrind, and tracing them to bugs in DConf.
Read more >Using WinDbg for the First Time - Damir's Corner
When logging and instrumentation are not enough to resolve the problem, it's time to create a memory dump and analyze it in WinDbg....
Read more >[SOLVED] Alienware 14 - CPU/GPU fan running at full speed ...
At 1 minutes and 54 seconds, a process called "Dell Instrumentation" will start using about 27% of the CPU and the fans will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using an x64 emulator solved the problem for me, as cristan commented here: https://github.com/mockk/mockk/issues/466#issuecomment-734758479
I agree with @NitroG42 .
I have migrated the few UI tests I had written to on a new mobile app project Mockito believing it would be way more stable thanks to its history and active development.
At first, it seemed the crashs were completely gone, but at some point they did reappear, still at random with the dreadful message from
InputDispatcher
and occasionalSIGSEGV
.On the Android TV project we have (which is way more advanced), the handful tests I developped, which required a lot more mocking, tended to crash a lot more (still on the emulator).
When migrating to Mockito, I noticed the same issues and restrictions:
android:extractNativeLibs="true"
as a workaround in the test manifestSo, if I understand correctly, MockK & Mockito uses the same APIs (from Android Test Instrumentation?) to perform mocking in Android UI tests.
While Mockito seemed, at first, a lot more stable, the crash eventually did reappear, for the same reasons. Could it be possible neither of them are the culprit?
Finally, I noticed that manually rebooting the emulators greatly reduced the random crash. Surely because it resets all the memory allocations, right?
@brettchabot could you help? Do you have any idea what could be the real issue?