wix / Detox

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

App launches but immediately closes #152

Closed talarari closed 6 years ago

talarari commented 7 years ago

i ran the example project and everything works fine. but when i run my project it launches the app and immediately closes it (goes back to home screen).

when i manually open the app on the simulator (after detox installed it), it launches fine.

we're running a react-native 0.42.3

any suggestions?

LeoNatan commented 7 years ago

It sounds like the app is crashing. Please provide the crash reason. You can use the Console app on macOS to see what the crash reason is.

devinceble commented 7 years ago

Same Here Produce Error Message: Currently Investigating the Issue It May Be Cause by some react-native package not detox

screen shot 2017-06-07 at 11 26 17 am

LeoNatan commented 7 years ago

I don’t see a crash information in that log print.

devinceble commented 7 years ago

The crash is "Service exited due to Abort trap: 6" mostly from links of react-native packages but XCODE would run the app without problems I think this is not detox problem.

LeoNatan commented 7 years ago

That's too generic. I cannot help if I don't know why this is happening.

Another way to discover the crash details is to change the scheme of your project to wait until you app is launch (like detailed here), press Play in Xcode, then run detox. This will make Xcode attach to the process spawned by Detox. If there is a crash, Xcode will breakpoint and show you. If you see it has stopped on objc_exception_throw, type po $arg1 in the debugger pane of Xcode.

tglanz commented 7 years ago

Tried to investigate this further by simulating what detox does manually and ran fbsimctl manually in all sorts of variations.

Apparently the situation happens only when setting the FBSIMCTL_CHILD_DYLD_INSERT_LIBRARIES environment variable to point to Detox.framework/detox path (as indicated in the getting started guid). If i remove the variable the application won't crash on startup (Of course that detox won't be able to run). Ran detox server (by detox run-server) and launched the app in the simulator, fbsimctl stderr output indicated an error: dyld: Symbol not found: __swiftEmptyDictionaryStorage Referenced from: [react native path]/node_modules/detox/Detox.framework/Detox Expected in: /Users/[me]/Library/Developer/CoreSimulator/Devices/671BEED2-A643-49F1-802B-B165F56A772F/data/Containers/Bundle/Application/C948219E-8AF4-4765-9742-AAC874D099E8/[the app file name].app/Frameworks/libswiftCore.dylib in /Users/[me]/[react native path]/node_modules/detox/Detox.framework/Detox

tglanz commented 7 years ago

Have managed to replicate the issue on the "demo-react-native" example app (from the repo) by replacing the objective-c files to swift code.

Am using swift 3.1

LeoNatan commented 7 years ago

Hmm. What Xcode version are you using? I think there may be a Swift library collision there.

tglanz commented 7 years ago

xcode 8.2.1

sriram289 commented 7 years ago

I tried to build the firefox-ios app with detox and the app crashes. I am also experiencing the same issue.

LeoNatan commented 7 years ago

Hang in there, guys, I will look for a solution early next week. I have taken this as top priority for me now.

tglanz commented 7 years ago

thanks, let us now if we could help with debugs

sameerpattanaik commented 7 years ago

Hi @LeoNatan , any update on the app crashing issue, as i was going through the example app for the demo react native project and the app is still crashing in iphone simulator.

LeoNatan commented 7 years ago

Which demo app did you run? This issue is specifically for Swift issues.

Regarding Swift, we have considered a solution, but I need help from guys that can help in JavaScript. CC @rotemmiz @silyevsk

sameerpattanaik commented 7 years ago

Hi Leo,

Thanks for the response, I tried the demo-react-native --ios , inside that we have example release app.

It is opening in the simulator but closing immediately. When running the detox test .

Thanks, Sameer

On Jul 18, 2017 13:53, "Leo Natan" notifications@github.com wrote:

Which demo app did you run? This issue is specifically for Swift issues.

Regarding Swift, we have considered a solution, but I need help from guys that can help in JavaScript. CC @rotemmiz https://github.com/rotemmiz @silyevsk https://github.com/silyevsk

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wix/detox/issues/152#issuecomment-316162663, or mute the thread https://github.com/notifications/unsubscribe-auth/AGdeprw3Oz0x3kz_mYeW4PmZJmuyHVyQks5sPP80gaJpZM4Nxc3D .

LeoNatan commented 7 years ago

@silyevsk Sergey, please assist here, how to enable logs to see what is happening?

silyevsk commented 7 years ago

When you run detox, there's a line that prints the logs location (every time it launches the app), it looks like this:

detox info 6: org.reactjs.native.example.example launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/EB9B3A90-621B-4F6E-815C-1E5C17ED5ABE/data/tmp/detox.last_launch_app_log.{out,err}

So in the above example the error log is $HOME/Library/Developer/CoreSimulator/Devices/EB9B3A90-621B-4F6E-815C-1E5C17ED5ABE/data/tmp/detox.last_launch_app_log.err

jlongster commented 7 years ago

This is the error that we are running into fwiw (we are using swift): https://gist.github.com/jlongster/0edb53ce69cbd038d65e207f9586a1d0

sameerpattanaik commented 7 years ago

Hi Sergey,

This is the log i am getting, please see is it making any sense to you.

2017-07-20 13:11:31.554 example[33158:5552408] Crash handler setup started. 2017-07-20 13:11:31.555 example[33158:5552408] Crash handler setup completed. 2017-07-20 13:11:31.555 example[33158:5552408] Enabling accessibility for automation on Simulator. 2017-07-20 13:11:31.690 example[33158:5552408] kGREYConfigKeyScreenshotDirLocation is to be deprecated in the 1.10.0 release. Please use the kGREYConfigKeyArtifactsDirLocation config key instead. 2017-07-20 13:11:32.081 example[33158:5552408] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.JSCExecutorQueue[0x6100000f2400]> 2017-07-20 13:11:32.099 example[33158:5552408] ☣️ DETOX:: Detox Action Sent: login 2017-07-20 13:11:32.233 [fatal][tid:main] No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your application bundle.unsanitizedScriptURLString:((null)) 2017-07-20 13:11:32.264 example[33158:5552408] Uncaught exception: No script URL provided. Make sure the packager is running or you have embed...; Stack trace: 0 CoreFoundation 0x000000010449bd4b exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010331f21e objc_exception_throw + 48 2 CoreFoundation 0x00000001045052b5 +[NSException raise:format:] + 197 3 example 0x0000000102a9ca20 RCTFatal + 393 4 example 0x0000000102abee44 -[RCTBatchedBridge stopLoadingWithError:] + 603 5 example 0x0000000102abbeef 25-[RCTBatchedBridge start]_block_invoke_2 + 42 6 EarlGrey 0x00000001130d63c4 60-[GREYDispatchQueueTracker grey_dispatchAsyncCallWithBlock:]_block_invoke + 36 7 libdispatch.dylib 0x00000001083bf808 _dispatch_call_block_and_release + 12 8 libdispatch.dylib 0x00000001083e112e _dispatch_client_callout + 8 9 libdispatch.dylib 0x00000001083c84fb _dispatch_main_queue_callback_4CF + 1054 10 CoreFoundation 0x000000010445fe49 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 11 CoreFoundation 0x000000010442537d CFRunLoopRun + 2205 12 CoreFoundation 0x0000000104424884 CFRunLoopRunSpecific + 420 13 GraphicsServices 0x000000010a309a6f GSEventRunModal

Thanks, sameer

On Thu, Jul 20, 2017 at 2:12 AM, Sergey Ilyevsky notifications@github.com wrote:

When you run detox, there's a line that prints the logs location (every time it launches the app), it looks like this:

detox info 6: org.reactjs.native.example.example launched. The stdout and stderr logs were recreated, you can watch them with: tail -F $HOME/Library/Developer/CoreSimulator/Devices/EB9B3A90-621B-4F6E-815C-1E5C17ED5ABE/data/tmp/detox.last_launch_app_log.{out,err}

So in the above example the error log is $HOME/Library/Developer/ CoreSimulator/Devices/EB9B3A90-621B-4F6E-815C-1E5C17ED5ABE/data/tmp/detox. last_launch_app_log.err

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wix/detox/issues/152#issuecomment-316617284, or mute the thread https://github.com/notifications/unsubscribe-auth/AGdepnnDGlaluifTWfkqwUoNH_eqwVTLks5sPv3OgaJpZM4Nxc3D .

-- Thanks, Sameer Pattanaik

rotemmiz commented 7 years ago

Looks like an issue with your bundle, which was not created for some reason 2017-07-20 13:11:32.233 [fatal][tid:main] No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your

Does the app work when you open it manually ?

jlongster commented 7 years ago

Does my error in https://github.com/wix/detox/issues/152#issuecomment-316781008 make any sense in light of this bug? I'm curious if I should wait until this is fixed to try again or I should investigate further. (no rush)

LeoNatan commented 7 years ago

Hmm this is a new issue. @jlongster Please open a new issue for that and attach the log. Thanks

sameerpattanaik commented 7 years ago

I am getting same response when opening the app manually.

On Thu, Jul 20, 2017 at 1:40 PM, Rotem Mizrachi-Meidan < notifications@github.com> wrote:

Looks like an issue with your bundle, which was not created for some reason 2017-07-20 13:11:32.233 [fatal][tid:main] No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your

Does the app work when you open it manually ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wix/detox/issues/152#issuecomment-316793520, or mute the thread https://github.com/notifications/unsubscribe-auth/AGdepnFTyZ2ZHE7wqGBojuYLBkLrYGi9ks5sP58JgaJpZM4Nxc3D .

-- Thanks, Sameer Pattanaik

tglanz commented 7 years ago

Hi, is there any update regarding this issue?

LeoNatan commented 7 years ago

Awaiting help from JS knowledgeable guys. 😞

isnifer commented 7 years ago

@tglanz @LeoNatan I have successfully integrated detox into our build process instead of appium (of course currently for iOS only). We're building our application with fastlane. Detox works sooooooo much better than appium (also so much faster). I'm sure that the main problem is the wrong build.

@tglanz did you test Release-iphonesimulator build?

madhu314 commented 7 years ago

Facing same issues as mentioned by @tglanz happens when AppDelegate is swift file, App crashes at line self.window = UIWindow(frame: UIScreen.main.bounds)

Also I can confirm that this does not happen with version "5.5.1"

@LeoNatan Is it possible that the fix made in https://github.com/wix/detox/commit/f46989b1033808918614a149b9858f6e9bf8bebd caused this regression ?

For now, I will continue using 5.5.1

Thanks!

LeoNatan commented 7 years ago

@madhu314 What is the exact reason for the crash? I cannot think of a reason for the window to cause a crash.

madhu314 commented 7 years ago

Hey @LeoNatan So I am running into EXC_BAD_ACCESS as soon as self.window is referred and app crashes with Segmentation Fault. So basically there is a bad memory reference

As I mentioned in the previous comment happens only with 5.60 and above, I don't see this problem with 5.5.1

LeoNatan commented 7 years ago

@madhu314 Please post a separate issue for this.

LeoNatan commented 6 years ago

This issue has been solved for a while.