Detox: Detox crashes on hidden input

Description

Detox crashes when using replaceText() or typeText() on hidden input with version 17.2.1. I always used this code with previous versions of Detox and never had any problem.

Reproduction

I’m trying to type on a hidden input (otp form) which is a TextInput:

const HiddenInput = styled.TextInput`
  height: 0;
  width: 0;
`;

To do this I’m using replaceText() but also tried with typeText(). If I change the height and width to 1 it works as expected.

Expected behavior

Fill the input without crash.

Environment (please complete the following information):

  • Detox: 17.2.1
  • React Native: 0.62.2
  • Node: 11.15.0
  • Device: iPhone 11 Pro
  • Xcode: 11.6
  • iOS: 13.6
  • macOS: 10.15.5

Device and verbose Detox logs

  • I have run my tests using the --loglevel trace argument and am providing the verbose log below:
detox[49607] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"invoke","params":{"type":"action","action":"replaceText","params":["000000"],"predicate":{"type":"id","value":"otpForm"}},"messageId":7}
detox[49607] TRACE: [DetoxServer.js/MESSAGE] role=tester action=invoke (sessionId=9a403d1e-6b8e-bea9-1905-da9c6c44a351)
detox[49607] TRACE: [DetoxServer.js/MESSAGE] role=testee action=AppWillTerminateWithError (sessionId=9a403d1e-6b8e-bea9-1905-da9c6c44a351)
detox[49607] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"AppWillTerminateWithError","params":{"queueName":"com.apple.main-thread","threadNumber":1,"errorDetails":"Invalid number value (NaN) in JSON write\n(\n\t0   CoreFoundation                      0x000000010e6a7e5e __exceptionPreprocess + 334\n\t1   libobjc.A.dylib                     0x000000010e0699b2 objc_exception_throw + 48\n\t2   Foundation                          0x00000001090e1de2 _writeJSONNumber + 1129\n\t3   Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371\n\t4   CoreFoundation                      0x000000010e730bb7 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 7\n\t5   CoreFoundation                      0x000000010e6a57a4 -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 196\n\t6   Foundation                          0x00000001090e2003 _writeJSONObject + 475\n\t7   Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371\n\t8   CoreFoundation                      0x000000010e730bb7 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 7\n\t9   CoreFoundation                      0x000000010e70a6da -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 250\n\t10  Foundation                          0x00000001090e2003 _writeJSONObject + 475\n\t11  Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371\n\t12  libswiftCore.dylib                  0x000000010ee0cb7d function signature specialization <Arg[0] = Dead> of Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 397\n\t13  libswiftCore.dylib                  0x000000010ebe9035 @objc Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 37\n\t14  Foundation                          0x00000001090e2003 _writeJSONObject + 475\n\t15  Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371\n\t16  libswiftCore.dylib                  0x000000010ee0cb7d function signature specialization <Arg[0] = Dead> of Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 397\n\t17  libswiftCore.dylib                  0x000000010ebe9035 @objc Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 37\n\t18  Foundation                          0x00000001090e2003 _writeJSONObject + 475\n\t19  Foundation                          0x00000001090df320 -[_NSJSONWriter dataWithRootObject:options:error:] + 86\n\t20  Foundation                          0x00000001090e13fa +[NSJSONSerialization dataWithJSONObject:options:error:] + 145\n\t21  Detox                               0x0000000107306cab Detox.WebSocket.sendAction(_: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> () + 939\n\t22  Detox                               0x000000010730cb52 partial apply forwarder for closure #1 () -> () in Detox.DetoxManager.(safeSend in _BFAF0574773C487E0D9A4521582DC83B)(action: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> () + 50\n\t23  Detox                               0x00000001072e5309 reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () + 25\n\t24  EarlGrey                            0x00000001336e6c18 __59-[GREYUIThreadExecutor executeSyncWithTimeout:block:error:]_block_invoke + 104\n\t25  EarlGrey                            0x00000001336971ca __54-[GREYRunLoopSpinner grey_checkConditionInActiveMode:]_block_invoke + 474\n\t26  CoreFoundation                      0x000000010e60babc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12\n\t27  CoreFoundation                      0x000000010e60b1b3 __CFRunLoopDoBlocks + 195\n\t28  CoreFoundation                      0x000000010e605f7d __CFRunLoopRun + 957\n\t29  CoreFoundation                      0x000000010e6058a4 CFRunLoopRunSpecific + 404\n\t30  EarlGrey                            0x0000000133696ebd -[GREYRunLoopSpinner grey_checkConditionInActiveMode:] + 381\n\t31  EarlGrey                            0x0000000133695b56 -[GREYRunLoopSpinner spinWithStopConditionBlock:] + 438\n\t32  EarlGrey                            0x00000001336e631f -[GREYUIThreadExecutor executeSyncWithTimeout:block:error:] + 1343\n\t33  EarlGrey                            0x00000001336e5d95 -[GREYUIThreadExecutor executeSync:error:] + 309\n\t34  Detox                               0x00000001072c0dde __45-[EarlGreyImpl(Detox) detox_safeExecuteSync:]_block_invoke + 141\n\t35  CoreFoundation                      0x000000010e60babc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12\n\t36  CoreFoundation                      0x000000010e60b1b3 __CFRunLoopDoBlocks + 195\n\t37  CoreFoundation                      0x000000010e60652b __CFRunLoopRun + 2411\n\t38  CoreFoundation                      0x000000010e6058a4 CFRunLoopRunSpecific + 404\n\t39  EarlGrey                            0x0000000133696ebd -[GREYRunLoopSpinner grey_checkConditionInActiveMode:] + 381\n\t40  EarlGrey                            0x0000000133695b56 -[GREYRunLoopSpinner spinWithStopConditionBlock:] + 438\n\t41  EarlGrey                            0x00000001336e631f -[GREYUIThreadExecutor executeSyncWithTimeout:block:error:] + 1343\n\t42  EarlGrey                            0x00000001336e5d95 -[GREYUIThreadExecutor executeSync:error:] + 309\n\t43  Detox                               0x00000001072c0dde __45-[EarlGreyImpl(Detox) detox_safeExecuteSync:]_block_invoke + 141\n\t44  CoreFoundation                      0x000000010e60babc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12\n\t45  CoreFoundation                      0x000000010e60b1b3 __CFRunLoopDoBlocks + 195\n\t46  CoreFoundation                      0x000000010e60652b __CFRunLoopRun + 2411\n\t47  CoreFoundation                      0x000000010e6058a4 CFRunLoopRunSpecific + 404\n\t48  GraphicsServices                    0x0000000110c14bbe GSEventRunModal + 139\n\t49  Detox                               0x00000001072cd316 __detox_UIApplication_run + 365\n\t50  UIKitCore                           0x0000000119287968 UIApplicationMain + 1605\n\t51  XXXXX                              0x0000000106ce5160 main + 112\n\t52  libdyld.dylib                       0x000000010f3d61fd start + 1\n\t53  ???                                 0x0000000000000006 0x0 + 6\n)"},"messageId":-10000}
detox[49607] ERROR: [Detox.js/APP_CRASH] App crashed in test 'Login should Login with the right credentials - individual user', here are the crash details:
Invalid number value (NaN) in JSON write
(
	0   CoreFoundation                      0x000000010e6a7e5e __exceptionPreprocess + 334
	1   libobjc.A.dylib                     0x000000010e0699b2 objc_exception_throw + 48
	2   Foundation                          0x00000001090e1de2 _writeJSONNumber + 1129
	3   Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371
	4   CoreFoundation                      0x000000010e730bb7 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 7
	5   CoreFoundation                      0x000000010e6a57a4 -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:] + 196
	6   Foundation                          0x00000001090e2003 _writeJSONObject + 475
	7   Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371
	8   CoreFoundation                      0x000000010e730bb7 __NSDICTIONARY_IS_CALLING_OUT_TO_A_BLOCK__ + 7
	9   CoreFoundation                      0x000000010e70a6da -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 250
	10  Foundation                          0x00000001090e2003 _writeJSONObject + 475
	11  Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371
	12  libswiftCore.dylib                  0x000000010ee0cb7d function signature specialization <Arg[0] = Dead> of Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 397
	13  libswiftCore.dylib                  0x000000010ebe9035 @objc Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 37
	14  Foundation                          0x00000001090e2003 _writeJSONObject + 475
	15  Foundation                          0x00000001090e2a33 ___writeJSONObject_block_invoke + 371
	16  libswiftCore.dylib                  0x000000010ee0cb7d function signature specialization <Arg[0] = Dead> of Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 397
	17  libswiftCore.dylib                  0x000000010ebe9035 @objc Swift._SwiftDeferredNSDictionary.enumerateKeysAndObjects(options: Swift.Int, using: @convention(block) (Swift.Unmanaged<Swift.AnyObject>, Swift.Unmanaged<Swift.AnyObject>, Swift.UnsafeMutablePointer<Swift.UInt8>) -> ()) -> () + 37
	18  Foundation                          0x00000001090e2003 _writeJSONObject + 475
	19  Foundation                          0x00000001090df320 -[_NSJSONWriter dataWithRootObject:options:error:] + 86
	20  Foundation                          0x00000001090e13fa +[NSJSONSerialization dataWithJSONObject:options:error:] + 145
	21  Detox                               0x0000000107306cab Detox.WebSocket.sendAction(_: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> () + 939
	22  Detox                               0x000000010730cb52 partial apply forwarder for closure #1 () -> () in Detox.DetoxManager.(safeSend in _BFAF0574773C487E0D9A4521582DC83B)(action: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> () + 50
	23  Detox                               0x00000001072e5309 reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () + 25
	24  EarlGrey                            0x00000001336e6c18 __59-[GREYUIThreadExecutor executeSyncWithTimeout:block:error:]_block_invoke + 104
	25  EarlGrey                            0x00000001336971ca __54-[GREYRunLoopSpinner grey_checkConditionInActiveMode:]_block_invoke + 474
	26  CoreFoundation                      0x000000010e60babc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	27  CoreFoundation                      0x000000010e60b1b3 __CFRunLoopDoBlocks + 195
	28  CoreFoundation                      0x000000010e605f7d __CFRunLoopRun + 957
	29  CoreFoundation                      0x000000010e6058a4 CFRunLoopRunSpecific + 404
	30  EarlGrey                            0x0000000133696ebd -[GREYRunLoopSpinner grey_checkConditionInActiveMode:] + 381
	31  EarlGrey                            0x0000000133695b56 -[GREYRunLoopSpinner spinWithStopConditionBlock:] + 438
	32  EarlGrey                            0x00000001336e631f -[GREYUIThreadExecutor executeSyncWithTimeout:block:error:] + 1343
	33  EarlGrey                            0x00000001336e5d95 -[GREYUIThreadExecutor executeSync:error:] + 309
	34  Detox                               0x00000001072c0dde __45-[EarlGreyImpl(Detox) detox_safeExecuteSync:]_block_invoke + 141
	35  CoreFoundation                      0x000000010e60babc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	36  CoreFoundation                      0x000000010e60b1b3 __CFRunLoopDoBlocks + 195
	37  CoreFoundation                      0x000000010e60652b __CFRunLoopRun + 2411
	38  CoreFoundation                      0x000000010e6058a4 CFRunLoopRunSpecific + 404
	39  EarlGrey                            0x0000000133696ebd -[GREYRunLoopSpinner grey_checkConditionInActiveMode:] + 381
	40  EarlGrey                            0x0000000133695b56 -[GREYRunLoopSpinner spinWithStopConditionBlock:] + 438
	41  EarlGrey                            0x00000001336e631f -[GREYUIThreadExecutor executeSyncWithTimeout:block:error:] + 1343
	42  EarlGrey                            0x00000001336e5d95 -[GREYUIThreadExecutor executeSync:error:] + 309
	43  Detox                               0x00000001072c0dde __45-[EarlGreyImpl(Detox) detox_safeExecuteSync:]_block_invoke + 141
	44  CoreFoundation                      0x000000010e60babc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	45  CoreFoundation                      0x000000010e60b1b3 __CFRunLoopDoBlocks + 195
	46  CoreFoundation                      0x000000010e60652b __CFRunLoopRun + 2411
	47  CoreFoundation                      0x000000010e6058a4 CFRunLoopRunSpecific + 404
	48  GraphicsServices                    0x0000000110c14bbe GSEventRunModal + 139
	49  Detox                               0x00000001072cd316 __detox_UIApplication_run + 365
	50  UIKitCore                           0x0000000119287968 UIApplicationMain + 1605
	51  XXXXX                              0x0000000106ce5160 main + 112
	52  libdyld.dylib                       0x000000010f3d61fd start + 1
	53  ???                                 0x0000000000000006 0x0 + 6
)
detox[49607] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"AppWillTerminateWithError","params":{"queueName":"com.apple.main-thread","threadNumber":1,"errorDetails":"Signal 6 was raised\n(\n\t0   Detox                               0x00000001072daa07 __DTXHandleSignal + 59\n\t1   libsystem_platform.dylib            0x000000010f7c55fd _sigtramp + 29\n\t2   ???                                 0x0000ffff00001faf 0x0 + 281470681751471\n\t3   libsystem_c.dylib                   0x000000010f4ffb7c abort + 120\n\t4   XXXXXX                              0x0000000106d36c0a CLSTerminateHandler() + 391\n\t5   libc++abi.dylib                     0x000000010eb40c87 std::__terminate(void (*)()) + 8\n\t6   libc++abi.dylib                     0x000000010eb435f0 __cxa_rethrow + 99\n\t7   libobjc.A.dylib                     0x000000010e069b46 objc_exception_rethrow + 37\n\t8   CoreFoundation                      0x000000010e605923 CFRunLoopRunSpecific + 531\n\t9   GraphicsServices                    0x0000000110c14bbe GSEventRunModal + 139\n\t10  Detox                               0x00000001072cd316 __detox_UIApplication_run + 365\n\t11  UIKitCore                           0x0000000119287968 UIApplicationMain + 1605\n\t12  XXXXXX                              0x0000000106ce5160 main + 112\n\t13  libdyld.dylib                       0x000000010f3d61fd start + 1\n\t14  ???                                 0x0000000000000006 0x0 + 6\n)"},"messageId":-10000}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

You should rethink what you are trying to implement. This is bad UX for your users.

Can you explain why it would be bad UX?

We have a similar issue, we wrote a custom OTP input, which relies on a hidden text input for opening the keyboard and handling user input. The custom OTP is only needed for customizing the component aesthetically, and I could argue it would be worse for the user to interact with a simple text input in this case, since it has to input a fixed amount of numbers.

Obviously, using a hidden text input is a caveat, but having no way (that I know of) for opening the keyboard and handling it manually, to me this seems the solution that leads to the best user experience.

Thanks. Please keep this repo alive. I’ll look soon.