Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application stopped at UIWindow creation while running tests on simulator #341

Closed
mfrachet opened this issue Oct 16, 2017 · 12 comments
Closed

Comments

@mfrachet
Copy link

Description

We're trying to use Detox in a quite big hybrid application but it seems an error occured while running our tests. After launching the simulator, the application starts and close instantly, showing us the following logs :

cat $HOME/Library/Developer/CoreSimulator/Devices/C7F3B9AA-BE83-43DE-971B-B4283D032E2C/data/tmp/detox.last_launch_app_log.err
objc[9803]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x119e7ecc0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x119c956f0). One of the two will be used. Which one is undefined.
2017-10-16 08:59:04.251 6play.debug[9803:6540818] Crash handler setup started.
2017-10-16 08:59:04.252 6play.debug[9803:6540818] Crash handler setup completed.
2017-10-16 08:59:04.252 6play.debug[9803:6540818] Enabling accessibility for automation on Simulator.
2017-10-16 08:59:04.445 6play.debug[9803:6540818] AdManager: registering renderer class: FWMetricsRenderer
2017-10-16 08:59:04.462 6play.debug[9803:6540818] Firebase automatic screen reporting is disabled. UIViewController transitions will not be automatically logged. To report screen transitions manually, call +[FIRAnalytics setScreenName:setScreenClass:].
Signal caught: Segmentation fault: 11
0   EarlGrey                            0x0000000120741979 grey_signalHandler + 249
1   libsystem_platform.dylib            0x000000010f4ceb3a _sigtramp + 26
2   ???                                 0x0000000000000018 0x0 + 24
3   6play.debug                         0x00000001061baad4 _TToFC11_play_debug11AppDelegate11applicationfTCSo13UIApplication29didFinishLaunchingWithOptionsGSqGVs10DictionaryVSC29UIApplicationLaunchOptionsKeyP____Sb + 180
4   Detox                               0x000000010668033a -[DetoxAppDelegateProxy application:didFinishLaunchingWithOptions:] + 232
5   UIKit                               0x000000010ad5a9b7 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 299
6   UIKit                               0x000000010ad5c29c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4119
7   UIKit                               0x000000010ad625e4 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1709
8   UIKit                               0x000000010ad5f7f3 -[UIApplication workspaceDidEndTransaction:] + 182
9   FrontBoardServices                  0x0000000112b795f6 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
10  FrontBoardServices                  0x0000000112b7946d -[FBSSerialQueue _performNext] + 186
11  FrontBoardServices                  0x0000000112b797f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
12  CoreFoundation                      0x000000010cb14c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
13  CoreFoundation                      0x000000010cafa0cf __CFRunLoopDoSources0 + 527
14  CoreFoundation                      0x000000010caf95ff __CFRunLoopRun + 911
15  CoreFoundation                      0x000000010caf9016 CFRunLoopRunSpecific + 406
16  UIKit                               0x000000010ad5e08f -[UIApplication _run] + 468
17  UIKit                               0x000000010ad64134 UIApplicationMain + 159
18  6play.debug                         0x0000000106162577 main + 55
19  libdyld.dylib                       0x000000010f19565d start + 1
20  ???                                 0x0000000000000006 0x0 + 6

The error occured while running our tests. The application starts and close automatically with the following log from test side :

  0 passing (4m)
  2 failing

  1) "before all" hook:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.


  2) "after all" hook:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

After some investigation, we manage to use Xcode Breakpoints to isolate the problem. It appears inside our AppDelegate :

window = UIWindow(frame: UIScreen.main.bounds)

What we did to avoid this issue

To ensure that Detox works outside our context but with the same constraint, we manage to create two different projects and have written tests for them.

The first one a is fully written with Swift 3, and the second one is a fully React Native project.
We manage to make all the test pass really really easily.

We've also taken care about different issues related to Firebase (that we're using inside our app, at firebase#issues).
The closest issue seems to be #152, but the Swift PR #277 doesn't help us.

Node, Device, Xcode and macOS Versions

  • Node: v8.4.0
  • Device: Simulator iPhone 7
  • Xcode: v8.3.3
  • macOS: v10.12.6
  • Swift: v3
  • Detox: v5.8.1
@LeoNatan
Copy link
Contributor

Hello,
Thanks for reporting.
When your breakpoint hits, what is the error you get on that line?
We used to have an issue where we swizzled the class of the app delegate object, causing cast issues in Swift, but that has been sorted out. I see nothing in that line that should trigger a crash, so it must be something else in the swizzling mechanism.

@vivalaakam
Copy link

Have similar problem

  • Node: 8.7.0
  • Device: Simulator iPhone 7
  • Xcode: 9.0
  • macOS: 5.8.3

@LeoNatan
Copy link
Contributor

Please provide the information requested.

@mfrachet
Copy link
Author

Quite busy these days, I m going to provide further information as soon as possible. Thanks for the interest.

@jykun
Copy link

jykun commented Oct 18, 2017

i have the same error. app starts and close instantly.
the error information like this:

"before all" hook:
Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

child_process.js:635
throw err;
^

Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts
at checkExecSyncError (child_process.js:592:13)
at Object.execSync (child_process.js:632:13)
at Object. (/Users/Kun/jijia_app_reactnative/node_modules/detox/local-cli/detox-test.js:46:4)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)

@LeoNatan
Copy link
Contributor

@jykun How did you determine your issue is related to this one? Please provide the device log.

@jykun
Copy link

jykun commented Oct 18, 2017

@LeoNatan
my app run detox build is ok, then run build test app is install on iPhone 7, and after app start it will close instantly.
thie terminal show like this:

node_modules/.bin/mocha e2e --opts e2e/mocha.opts
detox-server info 18:22:45: server listening on localhost:61819...
detox info 1: Searching for device matching iPhone 7...
detox info 3: Uninstalling cn.tuofeng.jijia...
detox info 3: cn.tuofeng.jijia uninstalled
detox info 4: Installing /Users/Kun/jijia_app_reactnative/ios/build/Build/Products/Debug-iphonesimulator/JiJiaApp.app...
detox info 4: /Users/Kun/jijia_app_reactnative/ios/build/Build/Products/Debug-iphonesimulator/JiJiaApp.app installed
detox info 5: Terminating cn.tuofeng.jijia...
detox info 5: cn.tuofeng.jijia terminated
detox info 6: Launching cn.tuofeng.jijia...
detox info 6: cn.tuofeng.jijia launched. The stdout and stderr logs were recreated, you can watch them with:
tail -F $HOME/Library/Developer/CoreSimulator/Devices/4990A07E-5D3A-43FC-8489-66528B5E430F/data/tmp/detox.last_launch_app_log.{out,err}

after long time, will show:

  1. "before all" hook

0 passing (2m)
1 failing

  1. "before all" hook:
    Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

child_process.js:635
throw err;
^
Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts
at checkExecSyncError (child_process.js:592:13)
at Object.execSync (child_process.js:632:13)
at Object. (/Users/Kun/jijia_app_reactnative/node_modules/detox/local-cli/detox-test.js:46:4)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)

ps: my colleague can run the same project, i can not run. i can test detox/example/demo-react-native.

@LeoNatan
Copy link
Contributor

LeoNatan commented Oct 18, 2017

after app start it will close instantly

That's too vague.

As you can see, the output tells you what to do:
tail -F $HOME/Library/Developer/CoreSimulator/Devices/4990A07E-5D3A-43FC-8489-66528B5E430F/data/tmp/detox.last_launch_app_log.{out,err}

This is the device log. Provide that and see if it is related to this issue or not.

@mfrachet
Copy link
Author

I've tried to reproduce, and having the following one inside my AppDelegate :

@UIApplicationMain
class AppDelegate: BaseAppDelegate {
    
    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
       /* ... */
    }
}

This line throws :

capture d ecran 2017-10-19 a 10 28 56

Like a

EXC_BAD_ACCESS

@LeoNatan
Copy link
Contributor

Interesting, thanks.

@LeoNatan
Copy link
Contributor

Fixed. Will be included in next build. CC @rotemmiz

@mfrachet
Copy link
Author

I m not sure if the issue is related, but we're having a EXC_BAD_INSTRUCTION while trying to use a local version of Detox on commit 1f11cab (the one closing this issue) :

Local detox

capture d ecran 2017-10-20 a 10 38 39

Simulator logs

capture d ecran 2017-10-20 a 10 38 47

Xcode breakpoint error

capture d ecran 2017-10-20 a 10 38 29

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants