linkedin / dexmaker

A utility for doing compile or runtime code generation targeting Android's Dalvik VM
Apache License 2.0
1.88k stars 249 forks source link

Breakpoints crash/hang debugger #161

Open smccants opened 4 years ago

smccants commented 4 years ago

Similar to the report https://github.com/linkedin/dexmaker/issues/100, but a different flavor.

When running with:

androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.25.1'

Any tests under debug crash if they have any breakpoints set. If I switch to:

androidTestImplementation 'org.mockito:mockito-android:2.13.0'

Breakpoints work fine. However, I'm looking to use the ability to mock final methods, so I'm hoping to get dexmaker-mockito-inline working correctly with the debugger.

This is running on real Android 9 hardware (Samsung Galaxy Tab A - 2019). It hangs the tablet is such a way that the easiest way to get it out of that state is to reboot the whole tablet.

Here is my build.gradle for the app:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.hcs.android.orconnect"
        minSdkVersion 24
        targetSdkVersion 28
        // The versionCode and versionName are defined in the top level (android) build.gradle file.
        versionCode versionValue
        versionName versionString
        testInstrumentationRunner "com.hcs.android.orconnect.junit.CustomTestRunner"
        multiDexEnabled true
        setProperty("archivesBaseName", "ORConnect-$versionName")
    }
    signingConfigs {
        config {
            storeFile file("$System.env.KEYSTORE_ANDROID")
            storePassword "$System.env.KEYPASSWORD_ANDROID"
            keyAlias "$System.env.KEYALIAS_ANDROID"
            keyPassword "$System.env.KEYPASSWORD_ANDROID"
            storeType "jks"
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    adbOptions {
        timeOutInMs 600000  // 10 minutes
    }
    packagingOptions {
        // Google's Speech-to-Text API doesn't know how to package its own stuff, so...
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/DEPENDENCIES'
    }
}

dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation ('net.java.dev.jna:jna:4.2.2')
    implementation project(':ORCService')
    implementation project(':ORCCommon')
    implementation project(':annotations')
    implementation files('../../../../lib/findBugs-2.0.2/annotations.jar')
    annotationProcessor project(':annotations')
    implementation project(':falcon') // Supports screenshots
    implementation 'com.github.anrwatchdog:anrwatchdog:1.4.0' // Used for ANR detection
    // CMU PocketSphinx - used for Wake Word detection
    implementation project(':pocketsphinx-android-5prealpha-release')
    implementation project(':models')
    // Kaldi - used for Wake Word detection
    implementation files('libs/speech/kaldi-android-5.2.aar')
    implementation project(':kaldi-model-small')
    // IBM Watson's Speech-To-Text and Text-To-Speech APIs
    implementation files('libs/speech/ibm-watson-android-sdk-0.5.1.aar')
    implementation ('com.ibm.watson:ibm-watson:8.0.0', {
        exclude group: 'com.google.code.findbugs' // We already have findbugs
        exclude group: 'org.mockito' // Mockito was included by IBM by mistake
    })
    // Google's Speech-To-Text cloud API stuff
    // Can't use com.google.cloud:google-cloud-speech:1.21+ because https://github.com/protocolbuffers/protobuf/issues/6718
    // once it picks up (yet to be released) protobuf-java-3.11.x we should be okay?
    implementation ('io.grpc:grpc-okhttp:1.25.0', {
        exclude group: 'com.google.code.findbugs' // Not even Google can keep dependencies straight - Program type already present: javax.annotation.CheckForNull
    })
    implementation ('com.google.cloud:google-cloud-speech:1.20.0', {
        exclude group: 'com.google.code.findbugs' // Not even Google can keep dependencies straight - Program type already present: javax.annotation.CheckForNull
    })

    testImplementation 'junit:junit:4.13'
    // We use Mockito because it doesn't need extra code to mock final classes.  We use
    // dexmaker-mockito-inline so that we can mock final methods.
    // JMock could work, if DexOpener worked (like JDave-Unfinalizer, but for DEX files), but
    // I was unable to make it work.  Hence I switched to Mockito, which is the favorite among Android
    // Developers (SMM)
//    testImplementation 'org.mockito:mockito-core:2.13.0'
//    testImplementation 'org.mockito:mockito-inline:2.13.0'
    testImplementation files('../../../../lib/jmock-2.8.4/hamcrest-core-1.3.jar')
    testImplementation files('../../../../lib/jmock-2.8.4/hamcrest-library-1.3.jar')
    testImplementation files('../../../../nb/ORCCommon/dist/ORCCommon-test.jar')
    testImplementation files('../../../../nb/CommonLibrary/dist/CommonLibrary-test.jar')
    testImplementation project(':pocketsphinx-android-5prealpha-release')
//    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.google.code.findbugs' // We already have findbugs
    })
//    androidTestImplementation 'org.mockito:mockito-android:2.13.0'
    androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito-inline:2.25.1'
}

apply from: "findbugs.gradle"

Here is the crash results:

Testing started at 10:49 AM ...

03/11 10:49:34: Launching ButtonBindingsTest
No apk changes detected since last installation, skipping installation of /home/smm/hcs/orc.trunk.java11/tablet/android/ORConnect/app/build/outputs/apk/debug/ORConnect-3.1.0-38566-debug.apk
No apk changes detected since last installation, skipping installation of /home/smm/hcs/orc.trunk.java11/tablet/android/ORConnect/app/build/outputs/apk/androidTest/debug/ORConnect-3.1.0-38566-debug-androidTest.apk
Running tests

$ adb shell am instrument -w -r   -e debug true -e class 'com.hcs.android.orconnect.ui.bindings.ButtonBindingsTest' com.hcs.android.orconnect.test/com.hcs.android.orconnect.junit.CustomTestRunner
Connecting to com.hcs.android.orconnect
Waiting for application to start debug server
Waiting for application to come online: com.hcs.android.orconnect | com.hcs.android.orconnect.test
Connecting to com.hcs.android.orconnect
Waiting for application to start debug server
Waiting for application to come online: com.hcs.android.orconnect | com.hcs.android.orconnect.test
Connecting to com.hcs.android.orconnect
Waiting for application to start debug server
Waiting for application to come online: com.hcs.android.orconnect | com.hcs.android.orconnect.test
Connecting to com.hcs.android.orconnect
Waiting for application to start debug server
Waiting for application to come online: com.hcs.android.orconnect | com.hcs.android.orconnect.test
Connecting to com.hcs.android.orconnect
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/droid.orconnec: The ClassLoaderContext is a special shared library.
I/droid.orconnec: The ClassLoaderContext is a special shared library.
I/droid.orconnec: The ClassLoaderContext is a special shared library.
I/droid.orconnec: The ClassLoaderContext is a special shared library.
W/droid.orconnec: Accessing hidden method Landroid/app/Instrumentation;->execStartActivity(Landroid/content/Context;Landroid/os/IBinder;Landroid/os/IBinder;Landroid/app/Activity;Landroid/content/Intent;ILandroid/os/Bundle;)Landroid/app/Instrumentation$ActivityResult; (light greylist, linking)
                  Accessing hidden method Landroid/app/Instrumentation;->execStartActivity(Landroid/content/Context;Landroid/os/IBinder;Landroid/os/IBinder;Ljava/lang/String;Landroid/content/Intent;ILandroid/os/Bundle;)Landroid/app/Instrumentation$ActivityResult; (light greylist, linking)
I/CustomTestRunner: Setting ORConnectApplication to run under test conditions.
I/droid.orconnec: Waiting for a blocking GC ClassLinker
I/droid.orconnec: WaitForGcToComplete blocked ClassLinker on ClassLinker for 31.393ms
W/ORConnectApplication: ORConnect Application has been switched to test mode.
I/AndroidJUnitRunner: Waiting for debugger to connect...
I/System.out: Sending WAIT chunk
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8603', transport: 'socket'
I/chatty: uid=10140(com.hcs.android.orconnect) identical 2 lines
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1461)
I/AndroidJUnitRunner: Debugger connected.
I/MonitoringInstr: Instrumentation started on process com.hcs.android.orconnect
I/MonitoringInstr: Setting context classloader to 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk", zip file "/data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk"],nativeLibraryDirectories=[/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/lib/arm, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/lib/arm, /data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk!/lib/armeabi-v7a, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk!/lib/armeabi-v7a, /system/lib]]]', Original: 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk", zip file "/data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk"],nativeLibraryDirectories=[/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/lib/arm, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/lib/arm, /data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk!/lib/armeabi-v7a, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk!/lib/armeabi-v7a, /system/lib]]]'
I/ORConnectApplication: OR Panel Application is now DEVICE OWNER.
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf in: PRE_ON_CREATE
I/ORConnectApplication: Created activity com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf
I/DecorView: createDecorCaptionView >> DecorView@c7e72eb[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
W/droid.orconnec: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/droid.orconnec: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf in: CREATED
I/ORConnectApplication: Started activity com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf
I/ORConnectApplication: Checking all permissions
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf in: STARTED
I/ORConnectApplication: Resumed activity com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf in: RESUMED
D/OpenGLRenderer: Skia GL Pipeline
D/EmergencyMode: [EmergencyManager] android createPackageContext successful
D/InputTransport: Input channel constructed: fd=72
D/ViewRootImpl@da0f531[LauncherActivity]: setView = DecorView@c7e72eb[LauncherActivity] TM=true MM=false
I/MonitoringInstr: No JSBridge.
D/ViewRootImpl@da0f531[LauncherActivity]: Relayout returned: old=[0,0][1920,1200] new=[0,0][1920,1200] result=0x7 surface={true 3736700928} changed=true
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 2
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/OpenGLRenderer: eglCreateWindowSurface = 0xe2505720, 0xdeb98808
D/ViewRootImpl@da0f531[LauncherActivity]: MSG_RESIZED: frame=[0,0][1920,1200] ci=[0,0][0,72] vi=[0,0][0,72] or=2
D/ViewRootImpl@da0f531[LauncherActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@c7e72eb[LauncherActivity]
                      getNavigationBarColor() -855310
D/InputMethodManager: prepareNavigationBarInfo() DecorView@c7e72eb[LauncherActivity]
D/InputMethodManager: getNavigationBarColor() -855310
V/InputMethodManager: Starting input: tba=com.hcs.android.orconnect ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : false , NavTrans : false
D/InputMethodManager: startInputInner - Id : 0
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=84
D/ViewRootImpl@da0f531[LauncherActivity]: MSG_RESIZED: frame=[0,0][1920,1200] ci=[0,0][0,72] vi=[0,0][0,0] or=2
D/InputMethodManager: prepareNavigationBarInfo() DecorView@c7e72eb[LauncherActivity]
D/InputMethodManager: getNavigationBarColor() -855310
V/InputMethodManager: Starting input: tba=com.hcs.android.orconnect ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : false , NavTrans : false
D/InputMethodManager: startInputInner - Id : 0
I/MonitoringInstr: Setting context classloader to 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk", zip file "/data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk"],nativeLibraryDirectories=[/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/lib/arm, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/lib/arm, /data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk!/lib/armeabi-v7a, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk!/lib/armeabi-v7a, /system/lib]]]', Original: 'dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk", zip file "/data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk"],nativeLibraryDirectories=[/data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/lib/arm, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/lib/arm, /data/app/com.hcs.android.orconnect.test-xTHoOLbkK9YyF9NvU50DaA==/base.apk!/lib/armeabi-v7a, /data/app/com.hcs.android.orconnect-s1norxADOcz2oKLHpsxJow==/base.apk!/lib/armeabi-v7a, /system/lib]]]'
I/UsageTrackerFacilitator: Usage tracking enabled
D/TestExecutor: Adding listener android.support.test.internal.runner.listener.LogRunListener
                Adding listener android.support.test.internal.runner.listener.InstrumentationResultPrinter
                Adding listener android.support.test.internal.runner.listener.ActivityFinisherRunListener
I/TestRunner: run started: 3 tests
E/MockMakerMultiplexer: Could not init mockmaker com.android.dx.mockito.inline.InlineStaticMockMaker
W/droid.orconnec: Accessing hidden method Ldalvik/system/VMDebug;->allowHiddenApiReflectionFrom(Ljava/lang/Class;)V (light greylist, reflection)
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 1 line
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
W/droid.orconnec: Accessing hidden field Lsun/misc/Unsafe;->theUnsafe:Lsun/misc/Unsafe; (light greylist, reflection)
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 2 lines
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 3 lines
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 5 lines
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
W/droid.orconnec: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled.
                  Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled.
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 3 lines
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
I/TestRunner: started: bindEnablesTest(com.hcs.android.orconnect.ui.bindings.ButtonBindingsTest)

Started running tests
I/MonitoringInstr: Activities that are still in CREATED to STOPPED: 1
I/MonitoringInstr: Finishing activity: com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf
I/MonitoringInstr: Unstopped activity count: 1
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 19 lines
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 1 line
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 6 lines
I/MonitoringInstr: Unstopped activity count: 1
I/MonitoringInstr: Unstopped activity count: 1
I/chatty: uid=10140(com.hcs.android.orconnect) ustomTestRunner identical 4 lines
I/MonitoringInstr: Unstopped activity count: 1
E/THREAD_STATE:   Thread[Binder:12023_4,5,main]

                  Thread[Signal Catcher,5,system]

                  Thread[FinalizerWatchdogDaemon,5,system]
                    java.lang.Thread.sleep(Native Method)
                    java.lang.Thread.sleep(Thread.java:373)
                    java.lang.Thread.sleep(Thread.java:314)
                    java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor(Daemons.java:342)
                    java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:364)
                    java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:281)
                    java.lang.Daemons$Daemon.run(Daemons.java:103)
                    java.lang.Thread.run(Thread.java:764)

                  Thread[Binder:12023_2,5,main]

                  Thread[FinalizerDaemon,5,system]
                    java.lang.Object.wait(Native Method)
                    java.lang.Object.wait(Object.java:422)
                    java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188)
                    java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209)
                    java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:232)
                    java.lang.Daemons$Daemon.run(Daemons.java:103)
                    java.lang.Thread.run(Thread.java:764)

                  Thread[HeapTaskDaemon,5,system]

                  Thread[Profile Saver,5,system]

                  Thread[queued-work-looper,5,main]
                    android.os.MessageQueue.nativePollOnce(Native Method)
                    android.os.MessageQueue.next(MessageQueue.java:326)
                    android.os.Looper.loop(Looper.java:181)
                    android.os.HandlerThread.run(HandlerThread.java:65)

                  Thread[Jit thread pool worker thread 0,5,main]

                  Thread[Binder:12023_3,5,main]

                  Thread[ReferenceQueueDaemon,5,system]
                    java.lang.Object.wait(Native Method)
                    java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:178)
                    java.lang.Daemons$Daemon.run(Daemons.java:103)
                    java.lang.Thread.run(Thread.java:764)

                  Thread[Instr: com.hcs.android.orconnect.junit.CustomTestRunner,5,main]
                    dalvik.system.VMStack.getThreadStackTrace(Native Method)
                    java.lang.Thread.getStackTrace(Thread.java:1538)
                    java.lang.Thread.getAllStackTraces(Thread.java:1588)
                    android.support.test.runner.MonitoringInstrumentation.getThreadState(MonitoringInstrumentation.java:636)
                    android.support.test.runner.MonitoringInstrumentation.dumpThreadStateToOutputs(MonitoringInstrumentation.java:631)
                    android.support.test.runner.MonitoringInstrumentation.waitForActivitiesToComplete(MonitoringInstrumentation.java:384)
                    android.support.test.runner.AndroidJUnitRunner$1.run(AndroidJUnitRunner.java:439)
                    android.support.test.internal.runner.listener.ActivityFinisherRunListener.testStarted(ActivityFinisherRunListener.java:48)
                    org.junit.runner.notification.SynchronizedRunListener.testStarted(SynchronizedRunListener.java:49)
                    org.junit.runner.notification.RunNotifier$3.notifyListener(RunNotifier.java:121)
                    org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
                    org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:118)
                    org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:42)
                    org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:323)
                    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
                    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
                    org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
                    org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
                    org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
                    org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
                    org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
                    org.junit.runners.ParentRunner.run(ParentRunner.java:363)
                    org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:79)
                    org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:85)
                    org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
                    org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163)
                    org.junit.runners.Suite.runChild(Suite.java:128)
                    org.junit.runners.Suite.runChild(Suite.java:27)
                    org.junit.runners.ParentRunner$3.run(ParentRunner.java:
W/MonitoringInstr: Still 1 activities active after waiting 2000 ms.
I/GrantPermissionCallable: Permission: android.permission.ACCESS_COARSE_LOCATION is already granted!
I/GrantPermissionCallable: Permission: android.permission.ACCESS_WIFI_STATE is already granted!
I/GrantPermissionCallable: Permission: android.permission.RECEIVE_BOOT_COMPLETED is already granted!
I/GrantPermissionCallable: Permission: android.permission.INTERNET is already granted!
I/GrantPermissionCallable: Permission: android.permission.RECORD_AUDIO is already granted!
I/GrantPermissionCallable: Permission: android.permission.READ_EXTERNAL_STORAGE is already granted!
I/GrantPermissionCallable: Permission: android.permission.WRITE_EXTERNAL_STORAGE is already granted!
I/GrantPermissionCallable: Permission: android.permission.READ_EXTERNAL_STORAGE is already granted!
I/GrantPermissionCallable: Permission: android.permission.CAMERA is already granted!
I/System.out: ORCService.__setReadyService(...) called!  This should only be called by tests setting a mocked service!
W/droid.orconnec: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
I/ORConnectApplication: Paused activity com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.LauncherActivity@1ff18cf in: PAUSED
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@aba1f33
D/ViewRootImpl@da0f531[LauncherActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@c7e72eb[LauncherActivity]
                      getNavigationBarColor() -855310
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.FragmentTestActivity@c7de3a1 in: PRE_ON_CREATE
I/ORConnectApplication: Created activity com.hcs.android.orconnect.activities.FragmentTestActivity@c7de3a1
I/DecorView: createDecorCaptionView >> DecorView@9868695[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.FragmentTestActivity@c7de3a1 in: CREATED
I/ORConnectApplication: Started activity com.hcs.android.orconnect.activities.FragmentTestActivity@c7de3a1
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.FragmentTestActivity@c7de3a1 in: STARTED
I/ORConnectApplication: Resumed activity com.hcs.android.orconnect.activities.FragmentTestActivity@c7de3a1
D/LifecycleMonitor: Lifecycle status change: com.hcs.android.orconnect.activities.FragmentTestActivity@c7de3a1 in: RESUMED
D/InputTransport: Input channel constructed: fd=91
D/ViewRootImpl@c384e[FragmentTestActivity]: setView = DecorView@9868695[FragmentTestActivity] TM=true MM=false
D/ViewRootImpl@c384e[FragmentTestActivity]: Relayout returned: old=[0,0][1920,1200] new=[0,0][1920,1200] result=0x7 surface={true 3736698880} changed=true
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/OpenGLRenderer: eglCreateWindowSurface = 0xe05c7de0, 0xdeb98008
D/ViewRootImpl@c384e[FragmentTestActivity]: MSG_RESIZED: frame=[0,0][1920,1200] ci=[0,36][0,72] vi=[0,0][0,0] or=2
D/ViewRootImpl@c384e[FragmentTestActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@9868695[FragmentTestActivity]
                      getNavigationBarColor() -855310
D/InputMethodManager: prepareNavigationBarInfo() DecorView@9868695[FragmentTestActivity]
                      getNavigationBarColor() -855310
V/InputMethodManager: Starting input: tba=com.hcs.android.orconnect ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : false , NavTrans : false
D/InputMethodManager: startInputInner - Id : 0
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=93
                  Input channel destroyed: fd=84
A/droid.orconnec: instrumentation.cc:267] Check failed: m == frame.method_ (m=0xe932ec58, frame.method_=0x708ab7b4) Expected void java.lang.Thread.sleep(java.lang.Object, long, int), Found void java.lang.Thread.sleep(java.lang.Object, long, int)
W/droid.orconnec: it should skip dumping thread list to prevent deadlock: exclusive owner ->12043

It does run is there are no breakpoints set, but that defeats the point of the debugger.

Please let me know if you need additional information. Thanks.

smccants commented 4 years ago

Edited the ticket to improve readability.

smccants commented 4 years ago

Maybe related: https://stackoverflow.com/questions/59037486/cannot-debug-android-instrumentedtest-activityscenario-koin-mocck

kkoser commented 4 years ago

Hi @smccants! Sorry for the delay here - I've been trying to repro this with your gradle setup, as well as the sample test linked in that SO post, but have not been able to repro the crash. Could you share some sample test code that causes the crash? I think especially important is understanding what you're trying to mock that causes it - I've tried mocking a bunch of final methods from various OS classes, and haven't had any problems with or without the debugger. A sample project would be awesome if you have the time. Thanks!!

smccants commented 4 years ago

@kkoser thanks for looking at this ticket. I spent about half a day trying to build a simple test case that would fail, but so far no luck. More interesting, as I pared down the existing test case, it didn't even require anything being mocked to crash. Also, the crash seems to occur at different places and occasionally not at all. It does seem to be time sensitive - I removed almost all of what I was testing (switching between activities by click) and the test would pass consistently. I added a sleep back in and the crash resumed. Best I can tell so far, it looks like a combination of some memory corruption with a race condition. I'm still working on a simple test case, but thought I'd update you on what I found so far.

kkoser commented 4 years ago

Thanks, that's useful! If it's a memory leak then it makes sense it would be time-related; theres probably some hidden limit that we hit after a certain amount of time depending on what's happening on the device. As for it requiring no mocking, that's really interesting - I'll try and see if anything stands out as dangerous in init code, although this bug may also be in the JVMTI implementation itself if that's the case...