google / EarlGrey

:tea: iOS UI Automation Test Framework
http://google.github.io/EarlGrey/
Apache License 2.0
5.62k stars 742 forks source link

earlgrey-2: Application crashes in simulator when not launched from XCode #1635

Open npamidisf opened 3 years ago

npamidisf commented 3 years ago

Hi,

Post integration of Earlgrey 2 into an app, i've noticed the app crashes when not launched via XCode, even if the prior launch through XCode was succesful(both if prior launch is directly through the app scheme or through ui tests scheme).

This is the crash log i was able to capture post the crash..

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called
CoreSimulator 772.1 - Device: iPhone 12 (****) - Runtime: iOS 14.5 (18E182) - DeviceType: iPhone 12

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff6030992e __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff603435bd pthread_kill + 263
2   libsystem_c.dylib               0x00007fff200fbcb5 abort + 120
3   com.google.earlgrey.AppFramework    0x0000000103ccfa9c +[GREYHostApplicationDistantObject testPort] + 204
4   com.google.earlgrey.AppFramework    0x0000000103cd599e -[GREYAppConfiguration init] + 366
5   com.google.earlgrey.AppFramework    0x0000000103cd5823 GREYCreateConfiguration + 35
6   com.google.earlgrey.AppFramework    0x0000000103d2bdb5 __40+[GREYConfiguration sharedConfiguration]_block_invoke + 21
7   libdispatch.dylib               0x00007fff201078df _dispatch_client_callout + 8
8   libdispatch.dylib               0x00007fff20108b16 _dispatch_once_callout + 20
9   com.google.earlgrey.AppFramework    0x0000000103d2bd74 +[GREYConfiguration sharedConfiguration] + 84
10  com.google.earlgrey.AppFramework    0x0000000103ca6853 -[NSObject(GREYApp) greyswizzled_performSelector:withObject:afterDelay:inModes:] + 227
11  com.apple.UIKitCore             0x00007fff23acaf37 -[UIApplication(UIKitApplicationAccessibility) _accessibilityInit] + 83
12  com.apple.UIKitCore             0x00007fff23aca516 _UIAccessibilityInitialize + 34
13  com.apple.UIKitCore             0x00007fff246c1171 -[UIApplication _run] + 34
14  com.apple.UIKitCore             0x00007fff246c639c UIApplicationMain + 101
15  com.salesforce.internal.kona    0x0000000101a9297d main + 125 (main.m:18)
16  libdyld.dylib                   0x00007fff2025abbd start + 1

Is there a way to prevent this from happening?

npamidisf commented 3 years ago

Also, curious if there is a way to completely stop any AppFramework or eDistantObject activity when not launched via UITests scheme?

Mattmlm commented 3 years ago

@npamidisf Not sure if this is what you're referring to, but have you tried configuring your app to run with this environment variable set? EarlGreyStandaloneMode

https://github.com/google/EarlGrey/blob/earlgrey2/AppFramework/Config/GREYAppConfiguration.m#L99

npamidisf commented 3 years ago

@npamidisf Not sure if this is what you're referring to, but have you tried configuring your app to run with this environment variable set? EarlGreyStandaloneMode

https://github.com/google/EarlGrey/blob/earlgrey2/AppFramework/Config/GREYAppConfiguration.m#L99

Yes, i did. I think the environment variable setting helps solve the issue where you won't even be able to run the app process via XCode...