wix / Detox

Gray box end-to-end testing and automation framework for mobile apps
https://wix.github.io/Detox/
MIT License
11.23k stars 1.92k forks source link

Crash in debug mode #1934

Closed compojoom closed 4 years ago

compojoom commented 4 years ago

Description

I'm running a test on our app in debug mode and detox crashes. Running the same test in release mode works fine.

The crash stack:

detox[68968] ERROR: [Detox.js/APP_CRASH] App crashed in test 'Payments tests Generating a receive payment should display correct screen', here's the native stack trace:
we should only have exactly one subview
(
    0   CoreFoundation                      0x00007fff23c7127e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff513fbb20 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23c70ff8 +[NSException raise:format:arguments:] + 88
    3   Foundation                          0x00007fff256e9c1a -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
    4   xxxapp                           0x000000010ba8a3a4 -[RCTScrollView layoutSubviews] + 340
    5   UIKitCore                           0x00007fff485784bd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
    6   QuartzCore                          0x00007fff2b131db1 -[CALayer layoutSublayers] + 255
    7   QuartzCore                          0x00007fff2b137fa3 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
    8   QuartzCore                          0x00007fff2b1438da _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
    9   QuartzCore                          0x00007fff2b08a848 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
    10  QuartzCore                          0x00007fff2b0bfb51 _ZN2CA11Transaction6commitEv + 643
    11  EarlGrey                            0x000000010d21e5c9 __61+[GREYVisibilityChecker grey_imageAfterAddingSubview:toView:]_block_invoke + 185
    12  EarlGrey                            0x000000010d21e8f9 +[GREYVisibilityChecker grey_prepareView:forVisibilityCheckAndPerformBlock:] + 665
    13  EarlGrey                            0x000000010d21e409 +[GREYVisibilityChecker grey_imageAfterAddingSubview:toView:] + 841
    14  EarlGrey                            0x000000010d21dcd8 +[GREYVisibilityChecker grey_captureBeforeImage:andAfterImage:andGetIntersectionOrigin:forView:withinRect:] + 4120
    15  EarlGrey                            0x000000010d21c736 +[GREYVisibilityChecker grey_percentViewVisibleOnScreen:withinRect:] + 182
    16  EarlGrey                            0x000000010d21c13e +[GREYVisibilityChecker grey_percentElementVisibleOnScreen:] + 254
    17  EarlGrey                            0x000000010d219627 +[GREYVisibilityChecker percentVisibleAreaOfElement:] + 263
    18  EarlGrey                            0x000000010d23dbc8 __45+[GREYMatchers matcherForSufficientlyVisible]_block_invoke + 88
    19  EarlGrey                            0x000000010d1ed439 -[GREYElementMatcherBlock matches:] + 89
    20  EarlGrey                            0x000000010d2143a6 -[GREYBaseMatcher matches:describingMismatchTo:] + 102
    21  EarlGrey                            0x000000010d1d7a5d -[GREYAllOf matches:describingMismatchTo:] + 509
    22  EarlGrey                            0x000000010d1d7a5d -[GREYAllOf matches:describingMismatchTo:] + 509
    23  EarlGrey                            0x000000010d1d77ea -[GREYAllOf matches:] + 170
    24  Detox                               0x000000010d0e6f06 __detox_grey_parent_block_invoke + 170
    25  EarlGrey                            0x000000010d1ed439 -[GREYElementMatcherBlock matches:] + 89
    26  EarlGrey                            0x000000010d2143a6 -[GREYBaseMatcher matches:describingMismatchTo:] + 102
    27  EarlGrey                            0x000000010d1d7a5d -[GREYAllOf matches:describingMismatchTo:] + 509
    28  EarlGrey                            0x000000010d1d7a5d -[GREYAllOf matches:describingMismatchTo:] + 509
    29  EarlGrey                            0x000000010d212960 -[GREYAnyOf matches:describingMismatchTo:] + 320
    30  EarlGrey                            0x000000010d2127aa -[GREYAnyOf matches:] + 170
    31  EarlGrey                            0x000000010d1e8ca9 -[GREYElementFinder elementsMatchedInProvider:] + 1161
    32  EarlGrey                            0x000000010d22d852 -[GREYElementInteraction matchedElementsWithTimeout:error:] + 1714
    33  EarlGrey                            0x000000010d2324fc __39-[GREYElementInteraction assert:error:]_block_invoke + 412
    34  EarlGrey                            0x000000010d263998 __59-[GREYUIThreadExecutor executeSyncWithTimeout:block:error:]_block_invoke + 104
    35  EarlGrey                            0x000000010d2114da __54-[GREYRunLoopSpinner grey_checkConditionInActiveMode:]_block_invoke + 474
    36  CoreFoundation                      0x00007fff23bd429c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    37  CoreFoundation                      0x00007fff23bd3a08 __CFRunLoopDoBlocks + 312
    38  CoreFoundation                      0x00007fff23bce86e __CFRunLoopRun + 1246
    39  CoreFoundation                      0x00007fff23bce066 CFRunLoopRunSpecific + 438
    40  EarlGrey                            0x000000010d2111cd -[GREYRunLoopSpinner grey_checkConditionInActiveMode:] + 381
    41  EarlGrey                            0x000000010d20fe66 -[GREYRunLoopSpinner spinWithStopConditionBlock:] + 438
    42  EarlGrey                            0x000000010d26309f -[GREYUIThreadExecutor executeSyncWithTimeout:block:error:] + 1343
    43  EarlGrey                            0x000000010d2317d7 -[GREYElementInteraction assert:error:] + 2055
    44  EarlGrey                            0x000000010d23331e -[GREYElementInteraction assertWithMatcher:error:] + 142
    45  Detox                               0x000000010d0e32b2 __56+[GREYCondition(Detox) detoxConditionForElementMatched:]_block_invoke + 100
    46  EarlGrey                            0x000000010d22c4b3 __46-[GREYCondition waitWithTimeout:pollInterval:]_block_invoke + 51
    47  EarlGrey                            0x000000010d21145b __54-[GREYRunLoopSpinner grey_checkConditionInActiveMode:]_block_invoke + 347
    48  CoreFoundation                      0x00007fff23bd429c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    49  CoreFoundation                      0x00007fff23bd3a08 __CFRunLoopDoBlocks + 312
    50  CoreFoundation                      0x00007fff23bce86e __CFRunLoopRun + 1246
    51  CoreFoundation                      0x00007fff23bce066 CFRunLoopRunSpecific + 438
    52  EarlGrey                            0x000000010d2111cd -[GREYRunLoopSpinner grey_checkConditionInActiveMode:] + 381
    53  EarlGrey                            0x000000010d20fe66 -[GREYRunLoopSpinner spinWithStopConditionBlock:] + 438
    54  EarlGrey                            0x000000010d22c24e -[GREYCondition waitWithTimeout:pollInterval:] + 750
    55  EarlGrey                            0x000000010d22bf4b -[GREYCondition waitWithTimeout:] + 75
    56  CoreFoundation                      0x00007fff23c7820c __invoking___ + 140
    57  CoreFoundation                      0x00007fff23c753af -[NSInvocation invoke] + 319
    58  Detox                               0x000000010d0e6832 +[DTXMethodInvocation invoke:onError:] + 816
    59  Detox                               0x000000010d0e1d25 __35-[TestRunner invoke:withMessageId:]_block_invoke + 142
    60  CoreFoundation                      0x00007fff23bd429c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    61  CoreFoundation                      0x00007fff23bd3a08 __CFRunLoopDoBlocks + 312
    62  CoreFoundation                      0x00007fff23bcee1b __CFRunLoopRun + 2699
    63  CoreFoundation                      0x00007fff23bce066 CFRunLoopRunSpecific + 438
    64  GraphicsServices                    0x00007fff384c0bb0 GSEventRunModal + 65
    65  Detox                               0x000000010d0e1025 __detox_UIApplication_run + 365
    66  UIKitCore                           0x00007fff48092d4d UIApplicationMain + 1621
    67  xxxapp                           0x000000010b7250d0 main + 112
    68  libdyld.dylib                       0x00007fff5227ec25 start + 1

Reproduction

The line it chokes on is not really very special:

    await waitFor(element(by.id("ReceiveQRCodeScreen").withDescendant(by.text("2"))))
      .toBeVisible()
      .withTimeout(3000)

grafik

Expected behavior

Expected not to crash in debug mode

Screenshots

If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

OS: macOS 10.15.3

SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1

IDEs: Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: @react-native-community/cli: 3.0.0-alpha.7 => 3.0.0-alpha.7 react: 16.9.0 => 16.9.0 react-native: 0.61.2 => 0.61.2 react-native-cli: 2.0.1

detox: 15.1.4

Logs

If you are experiencing a timeout in your test

If you are seeing a build problem (e.g. during npm install)

Device and verbose Detox logs

LeoNatan commented 4 years ago

Uhh 🤦‍♂️

This is a known bug in RN+EarlGrey. The way EG tests for visibility is by adding a subview, but that causes a crash in RN because for some reason they decide to crash. Not much we can do. I can suggest not testing visibility on scroll views. This will be sorted out in our rewrite.

LeoNatan commented 4 years ago

As a workaround, you can also disable the assertion in the RN code while debugging to prevent the crash.

compojoom commented 4 years ago

Aaaah, thanks @LeoNatan ! I saw an issue that was talking about that, but I thought you guys were talking about checking whether a ScrollView is visible and what I do is check whether an element in the scrollview is visible.

All right! I wrapped the scrollview and moved the testID from it to the View. Test pass in debug mode as well.

Thanks again!