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

Add exception and signal handling for iOS #453

Merged
merged 8 commits into from
Feb 8, 2018
Merged

Add exception and signal handling for iOS #453

merged 8 commits into from
Feb 8, 2018

Conversation

LeoNatan
Copy link
Contributor

@LeoNatan LeoNatan commented Dec 6, 2017

Closes #161 once @rotemmiz adds JS support.

@DanielMSchmidt
Copy link
Contributor

Do we need sth similar on Android?

@LeoNatan
Copy link
Contributor Author

LeoNatan commented Dec 6, 2017

Probably, yes. On Android, I would assume, the “attach vector” is larger, where you have Java exceptions, in addition to C++ and signals.

@LeoNatan
Copy link
Contributor Author

LeoNatan commented Dec 7, 2017

Moved the exception handling to std::set_terminate instead of NSSetUncaughtExceptionHandler in order to support C++ exceptions as well as ObjC exceptions (ObjC uses C++ exceptions ABI internally).

@LeoNatan
Copy link
Contributor Author

LeoNatan commented Dec 7, 2017

This will probably be useful for Android as well.

@@ -0,0 +1,153 @@
//
// DetoxCrashHandler.m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably You forgot about one m in extension 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was an Objective C file before, but now Objective C++.

@LeoNatan LeoNatan added this to To Do in Features Dec 17, 2017
@LeoNatan LeoNatan moved this from To Do to In Progress in Features Dec 17, 2017
rotemmiz and others added 3 commits January 29, 2018 15:20
# Conflicts:
#	detox/ios/Detox.xcodeproj/project.pbxproj
#	detox/ios/Detox/DetoxManager.m
# Conflicts:
#	detox/ios/Detox/DetoxManager.h
#	detox/ios/Detox/DetoxManager.m
#	detox/ios/Detox/TestRunner.m
@rotemmiz
Copy link
Member

rotemmiz commented Feb 8, 2018

Initial implementation for iOS + JS is ready. If app crashes it should now throw an error and fail the test, it will also restart the app to get it in working state again.

@rotemmiz rotemmiz merged commit a2bf0f0 into master Feb 8, 2018
@LeoNatan LeoNatan deleted the CrashHandling branch March 12, 2018 20:02
@rengarima
Copy link

rengarima commented Apr 23, 2018

My tests are still hanging after upgrading to this version - the app crashes due to a bug in react-native-datepicker 1.7.1 version in "Release" mode. The test still hangs and nothing happens , does this fix works on most scenarios? There is nothing in Detox logs but I get the error in Device logs

Detox version : 7.3.3
React-native: "0.52.3"

Error Trace after adding try catch in tests

    value@1271:1411
    mountClassInstance@89:28898
    beginWork@89:39550
    n@89:51871
    i@89:52212
    o@89:52558
    k@89:56698
    C@89:56241
    batchedUpdates@89:60070
    _e@89:14043
    He@89:14814
    receiveTouches@89:15357
    value@62:3471
    <unknown>@62:956
    value@62:2898
    value@62:928

    (
    	0   CoreFoundation                      0x000000010dc33b0b __exceptionPreprocess + 171
    	1   libobjc.A.dylib                     0x000000010c13f141 objc_exception_throw + 48
    	2   workbench                           0x000000010abe58b4 RCTFormatError + 0
    	3   workbench                           0x000000010abe2678 -[RCTExceptionsManager reportFatalException:stack:exceptionId:] + 507
    	4   CoreFoundation                      0x000000010dbbbc6c __invoking___ + 140
    	5   CoreFoundation                      0x000000010dbbbb40 -[NSInvocation invoke] + 320
    	6   CoreFoundation                      0x000000010dbd3956 -[NSInvocation invokeWithTarget:] + 54
    	7   workbench                           0x000000010abf8e85 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 600
    	8   workbench                           0x000000010ac3c1b4 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 266
    	9   workbench                           0x000000010ac3bf2d ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 78
    	10  EarlGrey                            0x000000011df9bf34 __60-[GREYDispatchQueueTracker grey_dispatchAsyncCallWithBlock:]_block_invoke + 36
    	11  libdispatch.dylib                   0x00000001121b8585 _dispatch_call_block_and_release + 12
    	12  libdispatch.dylib                   0x00000001121d9792 _dispatch_client_callout + 8
    	13  libdispatch.dylib                   0x00000001121bf237 _dispatch_queue_serial_drain + 1022
    	14  libdispatch.dylib                   0x00000001121bf98f _dispatch_queue_invoke + 1053
    	15  libdispatch.dylib                   0x00000001121bfd31 _dispatch_queue_override_invoke + 374
    	16  libdispatch.dylib                   0x00000001121c1899 _dispatch_root_queue_drain + 813
    	17  libdispatch.dylib                   0x00000001121c150d _dispatch_worker_thread3 + 113
    	18  libsystem_pthread.dylib             0x000000011256c169 _pthread_wqthread + 1387
    	19  libsystem_pthread.dylib             0x000000011256bbe9 start_wqthread + 13
    )
        at Client.execute (<...>/node_modules/detox/src/client/Client.js:72:13)
        at <anonymous>

@DanielMSchmidt DanielMSchmidt moved this from In Progress to Done in Features May 12, 2018
@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
Features
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants