JSON text must at least contain two octets when sending "uia.typeString"

566 views
Skip to first unread message

Aaron Zelick

unread,
Aug 7, 2014, 3:36:19 PM8/7/14
to calaba...@googlegroups.com
I am experiencing the issue when trying to use typeString on the iPad simulator (iOS 7.1). As you can see from the debug console log tapOffset is working but not typeString. This is failing 100% of the time in the same spot for me.


Sending UIA command
uia
.tapOffset('{:x 165, :y 100}')
Result
{"status"=>"success", "value"=>true, "index"=>0}
Sending UIA command
uia
.typeString('ios.test.automation.sell1', '')


JSON
::ParserError: A JSON text must at least contain two octets!



When I dig into the code using the debugger this is what I see: 
res = http({:method => :post, :path => 'uia'}, {:command => command}.merge(options))



        
inside 'def uia(command,options={})' in uia.rb is failing. 
with:
command = "uia.typeString('ios.test.automation.sell1', '')"

and 
options = ''


This http method is returning 'nil' which is then failing the JSON parser. The app also crashes. 
Here is the console log from the Thread that crashed:

Application Specific Information:

iPhone
Simulator 463.9.41, iPhone OS 7.1 (iPad Retina/11D167)
 


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib         0x071d5286 __kill + 10
1   libsystem_kernel.dylib         0x071d35ec kill$UNIX2003 + 32
2   libsystem_sim_c.dylib         0x06eda35b raise + 26
3   eBay                           0x0155988c CLSSignalHandler + 246
4   libsystem_platform.dylib       0x070a9deb _sigtramp + 43
5   CoreFoundation                 0x06a7523e CFStringCreateWithFormat + 46
6   CoreFoundation                 0x06b8df2f couldNotInstantiate + 63
7   UIKit                         0x05bb9741 -[UIView(AdditionalLayoutSupport) _edgeExpressionInContainer:vertical:max:] + 45
8   UIKit                         0x05bbaa47 -[UIView(AdditionalLayoutSupport) nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:] + 900
9   Foundation                     0x02bb1edd lower_1_attribute + 159
10  Foundation                     0x02bb1c3c -[NSLayoutConstraint _lowerIntoExpression:reportingConstantIsRounded:] + 165
11  Foundation                     0x02a2e4fb -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 97
12  Foundation                     0x02a319ad -[NSLayoutConstraint _addToEngine:] + 56
13  UIKit                         0x05bb7974 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 515
14  Foundation                     0x02ba868c -[NSISEngine withBehaviors:performModifications:] + 107
15  Foundation                     0x02a383c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
16  UIKit                         0x05bb7e40 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 63
17  UIKit                         0x05bb7754 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 476
18  UIKit                         0x05bb7e48 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 71
19  UIKit                         0x05bb754f -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 223
20  UIKit                         0x0557c24d __40-[UIView(Hierarchy) layoutBelowIfNeeded]_block_invoke + 416
21  Foundation                     0x02ba868c -[NSISEngine withBehaviors:performModifications:] + 107
22  Foundation                     0x02a383c5 -[NSISEngine withAutomaticOptimizationDisabled:] + 48
23  UIKit                         0x0557bf1a -[UIView(Hierarchy) layoutBelowIfNeeded] + 327
24  UIKit                         0x0557bdcd -[UIView(Hierarchy) layoutIfNeeded] + 74
25  eBay                           0x0056d9a9 -[EBUCollectionsSectionController collectionView:cellForItemAtIndexPath:] + 1273 (EBUCollectionsSectionController.m:117)
26  eBay                           0x000c225a -[EBUContentController collectionView:cellForItemAtIndexPath:] + 202 (EBUContentController.m:368)
27  UIKit                         0x05b60b30 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 257
28  UIKit                         0x05b62775 -[UICollectionView _updateVisibleCellsNow:] + 4730
29  UIKit                         0x15a0d058 __90-[UICollectionViewAccessibility(SafeCategory) accessibilityCreatePrepareCellForIndexPath:]_block_invoke145 + 44
30  AccessibilityUtilities         0x14113476 AXPerformSafeBlock + 26
31  UIKit                         0x15a0cd3b -[UICollectionViewAccessibility(SafeCategory) accessibilityCreatePrepareCellForIndexPath:] + 387
32  UIKit                         0x15a0d4ed -[UICollectionViewAccessibility(SafeCategory) accessibilityCellForRowAtIndexPath:] + 301
33  UIKit                         0x15a35d28 -[UICollectionViewCellAccessibilityElement cell] + 1209
34  UIKit                         0x15a35f47 -[UICollectionViewCellAccessibilityElement accessibilityFrame] + 34
35  UIAccessibility               0x140c0fd5 -[NSObject(AXPrivCategory) accessibilityAttributeValue:] + 1789
36  UIAccessibility               0x140b4b95 _copyAttributeValueCallback + 151
37  AXRuntime                     0x14073404 _AXXMIGCopyAttributeValue + 139
38  AXRuntime                     0x1406e0c0 _XCopyAttributeValue + 322
39  AXRuntime                     0x140796b4 mshMIGPerform + 256
40  CoreFoundation                 0x06a6cca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
41  CoreFoundation                 0x06a6c9db __CFRunLoopDoSource1 + 523
42  CoreFoundation                 0x06a9768c __CFRunLoopRun + 2156
43  CoreFoundation                 0x06a969d3 CFRunLoopRunSpecific + 467
44  CoreFoundation                 0x06a967eb CFRunLoopRunInMode + 123
45  GraphicsServices               0x0755d5ee GSEventRunModal + 192
46  GraphicsServices               0x0755d42b GSEventRun + 104
47  UIKit                         0x0551af9b UIApplicationMain + 1225
48  eBay                           0x00200bfc main + 76 (main.m:23)
49  libdyld.dylib                 0x0709f701 start + 1


Any help you can provide would be awesome!

Also I'm on calabash 0.9.168

Isaac Sachs

unread,
Aug 7, 2014, 4:06:40 PM8/7/14
to calaba...@googlegroups.com
Aaron and I are working on the same codebase at eBay and I'm also having this problem, using the iPhone 4" non-64-bit simulator.  This has also been an issue for our teammate using physical devices.  Trying Calabash 0.9.169 did not help.

We've tried Jani Jegoroff's solution here - https://github.com/calabash/calabash-ios/issues/259#issuecomment-35722777 - without success.  One thing I've noticed is that even one unrelated commit to the app can change the behavior (a button not causing crashes -> causing crashes and causing crashes -> not causing crashes) of this bug.  This issue has gone away and returned several times for me now over the course of the past few months, and the changes to the app in that time have not been related to the areas that have caused crashes.

In my experience, although a button press in a particular might crash 100% of the time, if I do the test completely manually, without cucumber, it will never crash.  If I execute the part of the test up to but not including that button press, then manually press that button, it will crash in the same way as if that button press had been done with automation.

Let us know if there's any other information we can provide.

-- Isaac

Jani Jegoroff

unread,
Aug 7, 2014, 4:07:30 PM8/7/14
to calaba...@googlegroups.com
What is your environment (calabash, Xcode, ruby)? Also post your 'gem list'.

I used to have same problem randomly but it was gone after I tuned my environment.
26  eBay                           0x000c225a -[EBUContentController collectionView:cellForItemAtIndexPath:] +<span style="color: #000;" class="styled-by-pre
...

Isaac Sachs

unread,
Aug 7, 2014, 4:17:44 PM8/7/14
to calaba...@googlegroups.com
We are using Xcode 5.1.1 on OSX 10.9 with Calabash 0.9.168.  This seems to be an issue with multiple different versions of ruby we've tried - 1.9.3, 2.0.0, or 2.1.0. The steps you listed as a resolution in issue #259 did not work for us.

The output of gem list:

*** LOCAL GEMS ***

activesupport (4.0.2, 3.2.13)
archive-tar-minitar (0.5.2)
atomic (1.1.14)
awesome_print (1.2.0, 1.1.0)
blankslate (3.1.2, 2.1.2.4)
builder (3.2.2)
bundler (1.5.3, 1.3.5, 1.2.3)
bundler-unload (1.0.2, 1.0.1)
calabash-common (0.0.1)
calabash-cucumber (0.9.168, 0.9.167, 0.9.166, 0.9.160)
CFPropertyList (2.2.8, 2.2.7, 2.2.0)
colored (1.2)
columnize (0.3.6)
cucumber (1.3.10, 1.3.8, 1.3.2)
debugger-ruby_core_source (1.3.1)
diff-lcs (1.2.5, 1.2.4)
dnssd (2.0)
docile (1.1.3)
ebm (0.0.38, 0.0.33, 0.0.31)
edn (1.0.2)
executable-hooks (1.3.1, 1.2.4)
frank-cucumber (1.2.2, 1.2.0)
gem-wrappers (1.2.4)
geocoder (1.1.9, 1.1.8)
gherkin (2.12.2, 2.12.1, 2.12.0)
highline (1.6.20, 1.6.19, 1.6.12)
httparty (0.12.0, 0.11.0)
httpclient (2.3.4.1, 2.3.3)
i18n (0.6.9, 0.6.5, 0.6.1)
json (1.8.1, 1.8.0)
json_pure (1.8.1, 1.8.0)
linecache19 (0.5.12)
location-one (0.0.10)
mime-types (2.1, 1.25)
minitest (4.7.5)
multi_json (1.8.4, 1.7.7)
multi_test (0.1.1, 0.0.3, 0.0.2)
multi_xml (0.5.5, 0.5.4)
parslet (1.5.0, 1.4.0)
plist (3.1.0)
rack (1.5.2)
rack-protection (1.5.2, 1.5.0)
rake (10.1.1, 10.0.4, 10.0.3)
rdoc (4.1.1)
rest-client (1.6.7)
retriable (1.4.1, 1.3.3.1)
rspec (2.14.1)
rspec-core (2.14.7, 2.14.4)
rspec-expectations (2.14.5, 2.14.1)
rspec-mocks (2.14.5, 2.14.3)
ruby-debug-base19x (0.11.30.pre15)
ruby-debug-ide (0.4.22)
ruby-hmac (0.4.0)
ruby_core_source (0.1.5)
rubygems-bundler (1.4.2, 1.3.4, 1.2.0, 1.1.0)
rubyzip (1.1.0, 0.9.9)
run_loop (0.2.1, 0.2.0, 0.1.4, 0.1.2, 0.0.21, 0.0.15)
rvm (1.11.3.9, 1.11.3.8, 1.11.3.5)
sim_launcher (0.4.11, 0.4.9, 0.4.6)
simplecov (0.8.2)
simplecov-html (0.8.0)
sinatra (1.4.4, 1.4.3)
slowhandcuke (0.0.3)
subcommand (1.0.6)
testrail (0.0.3)
thor (0.18.1)
thread_safe (0.1.3)
tilt (2.0.0, 1.4.1)
tzinfo (0.3.38)
xamarin-test-cloud (0.9.29, 0.9.28, 0.9.26)
xcodeproj (0.17.0, 0.14.1, 0.13.1)

Isaac Sachs

unread,
Aug 7, 2014, 4:33:04 PM8/7/14
to calaba...@googlegroups.com
To follow the convention in here more closely:

nat-dhcp-254-92:~ isachs$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
nat-dhcp-254-92:~ isachs$ xcodebuild -version
Xcode 5.1.1
Build version 5B1008
nat-dhcp-254-92:~ isachs$ calabash-ios version
0.9.168
nat-dhcp-254-92:~ isachs$ calabash-ios console
Running irb...
irb(main):001:0> server_version
{
                        "outcome" => "SUCCESS",
                         "app_id" => "com.ebay.iphone",
               "simulator_device" => "iPhone",
                        "version" => "0.9.168",
                       "app_name" => "eBay",
    "iphone_app_emulated_on_ipad" => false,
                          "4inch" => true,
                            "git" => {
        "remote_origin" => "g...@github.com:jmoody/calabash-ios-server.git",
               "branch" => "master",
             "revision" => "adde106"
    },
                    "app_version" => "3.4.0",
                    "iOS_version" => "7.1",
                         "system" => "x86_64",
                      "simulator" => "iPhone Simulator 463.9.41, iPhone OS 7.1 (iPhone Retina (4-inch)/11D167)"
}

Jani Jegoroff

unread,
Aug 7, 2014, 4:58:57 PM8/7/14
to calaba...@googlegroups.com
Okay, are you sure you followed the steps I provided? I mean this gem list looks suspicious to me since there are quite a lot of old versions. One step is to execute 'gem cleanup' to remove these old gem versions.
I had old gem versions too and I'm pretty sure that was the root cause for this issue in my case.

Isaac Sachs

unread,
Aug 7, 2014, 5:15:38 PM8/7/14
to calaba...@googlegroups.com
Yes, I'm sure.  I had created a new Ruby with rvm to try to debug this, but I'm currently back on the one that had been otherwise working for me.  This has also been a problem on a teammate's (relatively) freshly imaged machine without old versions of anything.

Jani Jegoroff

unread,
Aug 7, 2014, 5:30:15 PM8/7/14
to calaba...@googlegroups.com
Hmm, I did those steps in three different computers and have not seen the problem was gone.

Isaac Sachs

unread,
Aug 7, 2014, 5:33:59 PM8/7/14
to calaba...@googlegroups.com
When the problem went away for you, had there been any change to the app you are testing?  As I mentioned, it seems like even the smallest unrelated change in the app can affect this problem.

Jani Jegoroff

unread,
Aug 7, 2014, 5:40:53 PM8/7/14
to calaba...@googlegroups.com
No, there was no change in the app. Have you tried my example project? Are you also able to reproduce with that?

Isaac Sachs

unread,
Aug 11, 2014, 6:46:57 PM8/11/14
to calaba...@googlegroups.com
Jani, where can I find your example project?

Jani Jegoroff

unread,
Aug 12, 2014, 4:35:25 AM8/12/14
to calaba...@googlegroups.com
Here: https://github.com/calabash/calabash-ios/issues/259#issuecomment-34732152

(I used it with older Calabash version so you need to update launch command)

Joshua Moody

unread,
Aug 12, 2014, 7:35:36 AM8/12/14
to calaba...@googlegroups.com

Issac and Aaron,

Are you using a Gemfile and bundler?

If not, can you try? I want to try to isolate this as much a possible. Ping me with a private message if you want instructions.

Also, are you using rbenv, rvm, or the Apple system ruby?

+1000 for a clear, concise, and formatted bug report.

Are both of those reports from the same crash?

This http method is returning 'nil' which is then failing the JSON parser. The app also crashes.

It is actually the other way around. The app crashes, which causes the embedded server to crash and the http response from the server is invalid json (usually "" or nil).

Crash Analysis

The crash is occurring when your custom EBUContentController is being asked for a cell. Can you log the arguments to that selector? Can you describe, which screenshots, the cell you are trying to touch? Does it appear at the edge of the screen?

26  eBay                           0x000c225a -[EBUContentController collectionView:cellForItemAtIndexPath:]+ 202 (EBUContentController.m:368)
27  UIKit                         0x05b60b30 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 257
28  UIKit                         0x05b62775 -[UICollectionView _updateVisibleCellsNow:] + 4730
29  UIKit                         0x15a0d058 __90-[UICollectionViewAccessibility(SafeCategory)accessibilityCreatePrepareCellForIndexPath:]_block_invoke145 + 44
30  AccessibilityUtilities         0x14113476 AXPerformSafeBlock + 26
31  UIKit                         0x15a0cd3b -[UICollectionViewAccessibility(SafeCategory)accessibilityCreatePrepareCellForIndexPath:] + 387
32  UIKit                         0x15a0d4ed -[UICollectionViewAccessibility(SafeCategory)accessibilityCellForRowAtIndexPath:] + 301
33  UIKit                         0x15a35d28 -[UICollectionViewCellAccessibilityElement cell] + 1209
34  UIKit                         0x15a35f47 -[UICollectionViewCellAccessibilityElement accessibilityFrame] +34
35  UIAccessibility               0x140c0fd5 -[NSObject(AXPrivCategory) accessibilityAttributeValue:] + 1789

From the stack trace, I see only UIA calls which might indicate a bug in UIAutomation.

Aaron Zelick

unread,
Aug 12, 2014, 1:30:50 PM8/12/14
to calaba...@googlegroups.com
It looks like Isaac and myself were getting the same JSON error but from different causes. My issue was the number of cells in a background collectionView. I wrote up more details here: https://github.com/calabash/calabash-ios/issues/259. The issue has been patched on our end by lowering the number of off screen cells that can be created. 

I just talked to Isaac and he will comment in a bit. He is trying to untangle exactly what he is seeing. 
Reply all
Reply to author
Forward
0 new messages