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

calabash - intermittent uia failures - "a JSON text must at least contain two octets!" #259

Closed
jmoody opened this issue Dec 11, 2013 · 50 comments
Assignees

Comments

@jmoody
Copy link
Contributor

jmoody commented Dec 11, 2013

Originally reported (on the forum)[http://tinyurl.com/ovwuv2u] as a problem with uia_type_string but I think that the real problem is with the uia function itself; it just manifests more often when typing text.

I experienced the same error using uia_tap_offset.

No steps to reproduce.

No sample project.

@ghost ghost assigned krukow Dec 11, 2013
@jmoody
Copy link
Contributor Author

jmoody commented Dec 11, 2013

Today I ran about 6.5 hours of tests:

  • 5.5h against devices (50/50 iphone/ipad)
  • 1h against iPhone Simulator
  • iOS 7.*
  • iPhone app emulated on an iPad

The tests involved lot's of typing + comparing and (of course) lot's of touching.

I encountered only one octet error (mentioned above).

Unfortunately, none of these were against an email keyboard.

Next Steps

  • run against email keyboard
  • run against an iPad keyboard

@krukow
Copy link
Contributor

krukow commented Dec 16, 2013

@jmoody Can you update this? Also I'd really appreciate if you could help me reproduce this somehow.

@jmoody
Copy link
Contributor Author

jmoody commented Dec 16, 2013

@krukow later today or tomorrow i am back on calabash-ios

@ghost ghost assigned jmoody Dec 18, 2013
jmoody added a commit to jmoody/briar-ios-example that referenced this issue Dec 18, 2013
@jmoody
Copy link
Contributor Author

jmoody commented Dec 19, 2013

cannot reproduce

I cannot reproduce this problem.

I am running the test suite again to confirm, but after many tens of thousands of characters, I haven't seen any "a JSON text must at least contain two octets!" problems.

I have seen one case where the ',' character was not typed correctly (no text was entered). I am trying to reproduce that.

NB I am running a version of calabash that includes this pull request: #258 which fixes problems on the iPad keyboard, but looking at the examples given by Niels and Riley, I don't see how the pull request could have 'fixed' their problem.

methodology

I started by trying to enter a bunch of emails into some Briar text fields.

I noticed that the 'faker' gem was not generating email addresses with numbers and letters, so I randomized the username portion of the email to contain numbers and letters. This was an attempt to reproduce the problem that Niels is seeing.

I then looked at Riley's use case and saw the ',' character. I decided to test against all the keys on the email keyboard. I generated random strings using all the characters on the keyboard with the exception of '' and '·' (the large dot).

  num.to_i.times {
    rnd_str = ''
    50.enum_for(:times).inject(rnd_str) do |result, index|
      sample = [*32..126].sample.chr
      # these do not exist on the email keyboard, so i replaced them
      sample = '‹' if sample.eql?('(')
      sample = '›' if sample.eql?(')')
      sample = '¥' if sample.eql?(':')
      sample = '£' if sample.eql?(';')

      # too annoying to handle
      sample = '€' if sample.eql?('\\')

      # did not bother trying to the large dot because i ran out of chars
      # sample = '·' if sample.eql?('\"')
      rnd_str << sample
    end

Below you can see the Scenarios I ran.

environment

  • Xcode 5.0.2
  • iOS 7.0.3 Simulator
  • Briar-cal 0.1.4
  • briar gem 0.1.3 (not that it matters - i only used vanilla calabash for the tests)
  • faker gem to generate fake emails
  • iPad
  • iPad Retina

Scenarios

@issue_259
Feature: uia_type_text should not throw octet problems

  Background: i am looking at the text related view
    Given I am looking at the Text tab

  @wip
  Scenario: i should be able to type one email address
    Then I type 1 email address into the text fields

  @wip
  Scenario: i should be able to type one random string
    Then I type 1 random string with the full range of characters into the text fields

  @wip
  Scenario: i should be able to type 10 email address
    Then I type 10 email addresses into the text fields

  @wip
  Scenario: i should be able to type 10 random string
    Then I type 10 random strings with the full range of characters into the text fields

  @wip
  Scenario: i should be able to type 100 email address
    Then I type 100 email addresses into the text fields

  @wip
  Scenario: i should be able to type 100 random string
    Then I type 100 random strings with the full range of characters into the text fields

  @wip
  Scenario: i should be able to type 1000 email address
    Then I type 1000 email addresses into the text fields

  @wip
  Scenario: i should be able to type 1000 random string
    Then I type 1000 random strings with the full range of characters into the text fields

calabash-ios version

$ be calabash-ios version
0.9.163.pre4

server_version

irb(main):051:0> server_version
{
             "outcome" => "SUCCESS",
              "app_id" => "com.littlejoysoftware.Briar-cal",
    "simulator_device" => "iPad",
             "version" => "0.9.163.pre3",
          "git branch" => "calabash-ios-server",
            "app_name" => "Briar-cal",
               "4inch" => false,
        "git revision" => "6a41a83",
         "app_version" => "0.1.4",
         "iOS_version" => "7.0.3",
              "system" => "x86_64",
           "simulator" => "iPhone Simulator 463.9.4.2, iPhone OS 7.0.3 (iPad Retina/11B508)"

@ghost ghost assigned krukow Dec 19, 2013
jmoody added a commit to jmoody/briar-ios-example that referenced this issue Dec 19, 2013
* added tests for issue 259
    - cannot reproduce
    - calabash/calabash-ios#259

* updates to Rakefile
    - removed irb scripts in favor of rake tasks
    - now using ideviceinstaller to remove and deploy (removed ios-deploy)
    - added rake task for setting the simulator default device (WIP)
@jmoody
Copy link
Contributor Author

jmoody commented Dec 19, 2013

I ran the test suite described above over night and could not reproduce.

@krukow
Copy link
Contributor

krukow commented Dec 19, 2013

@jmoody good work. Closing this issue. Please reopen if the issue reproduces.

@jmoody
Copy link
Contributor Author

jmoody commented Jan 14, 2014

as of 0.9.165 this has started to appear for some users when interacting with the keyboard.

@krukow
Copy link
Contributor

krukow commented Jan 30, 2014

Can you get more details - is this still an issue on 0.9.166? In this version (on the 0.9.x branch), typeString on UIA was improved to be more robust.

@sergey-plevako
Copy link

I have the same crash when touching some text on the screen. It crashes sometimes when touch is performed on different text, though.
touch "label text:'Some text'"
uia.tapOffset('{:x 148, :y 174}')

  A JSON text must at least contain two octets! (JSON::ParserError)
  /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/json/common.rb:148:in `initialize'
  /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/json/common.rb:148:in `new'
  /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/json/common.rb:148:in `parse'

calabash-ios version 0.9.165
xCode Version 5.0.2 (5A3005)
iOS Simulator Version 7.0 (463.9.4.2)

@Reedyuk
Copy link

Reedyuk commented Feb 5, 2014

I can confirm, i was also getting this error but since moving to 166, it has now gone. Thanks!

@jmoody
Copy link
Contributor Author

jmoody commented Feb 7, 2014

calabash exposed a bug in Apple's UIAutomation (divide by zero).

0.9.166 detects this bug and tries to cope with it.

@jmoody jmoody closed this as completed Feb 7, 2014
@StCredZero
Copy link

This seems to still affect 0.9.166:

  Scenario: Login touch menu            # features/my_first.feature:27
    Given I log in                      # features/step_definitions/my_first_steps.rb:7
      A JSON text must at least contain two octets! (JSON::ParserError)
      /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/json/common.rb:155:in `initialize'
      /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/json/common.rb:155:in `new'
      /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/json/common.rb:155:in `parse'
      ./features/step_definitions/my_first_steps.rb:9:in `/^I log in$/'
      features/my_first.feature:28:in `Given I log in'
    Then I touch "Skip"                 # calabash-cucumber-0.9.166/features/step_definitions/calabash_steps.rb:15
    Then I touch the "iconSlide" button # calabash-cucumber-0.9.166/features/step_definitions/calabash_steps.rb:31
    Then I should see "Section One"     # calabash-cucumber-0.9.166/features/step_definitions/calabash_steps.rb:340

@jmoody
Copy link
Contributor Author

jmoody commented Feb 8, 2014

@StCredZero - is this on the simulator or adevice? which iOS?

@jmoody jmoody reopened this Feb 10, 2014
@StCredZero
Copy link

Joshua,

It was on the simulator. (4" iPhone, not 64-bit) iOS 7.

We've rolled back to 0.9.162 and can proceed this way.

--Peter

On Fri, Feb 7, 2014 at 6:23 PM, Joshua Moody notifications@github.comwrote:

@StCredZero https://github.com/StCredZero - is this on the simulator or
adevice? which iOS?

Reply to this email directly or view it on GitHubhttps://github.com//issues/259#issuecomment-34525996
.

There's neither heaven nor hell,
save what we grant ourselves.
There's neither fairness nor justice,
save what we grant each other.

@jmoody
Copy link
Contributor Author

jmoody commented Feb 10, 2014

@krukow

As off 0.9.166, users are still reporting problems with uia_type_string and uia.tapOffset.

@krukow
Copy link
Contributor

krukow commented Feb 11, 2014

@jmoody - I've not seen this on 0.9.166 so we really need a way to reproduce it.

@krukow I am working on getting an example - scroll to the bottom of this forum post.

thanks @JaniJegoroff

project - https://github.com/JaniJegoroff/calabash-ios-example-json-issue

@StCredZero Can we see the step definition for Given I log in? , as well as output of gem list, and server_version? Also which Xcode version?

@tomquist
Copy link

tomquist commented Aug 1, 2014

We get the same error on random scenarios (one out of 400) using Calabash 0.9.169. Sometimes we get
Connection refused - connect(2) (http://localhost:37265) (Errno::ECONNREFUSED) instead of the above error. The two errors could possibly be related.

@ShirleyFeng
Copy link

I have the same issue as @tomquist mentioned. I have multiple scenario in one feature file. I experienced intermittent Connection refused - connect(2) (http://localhost:37265) (Errno::ECONNREFUSED) error and just now I encountered "a JSON text must at least contain two octets" I am using Calabash 0.9.169 as well.

@azelder
Copy link

azelder commented Aug 7, 2014

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

One other thing I'm pursuing is that we are using a custom UITextField that could be causing a problem.

Any help you can provide would be awesome!

Also I'm on calabash 0.9.168

@JAmarlapudi
Copy link

It still occurs for me when I'm using running any uia commands in console.

irb(main):012:0> start_test_server_in_background
Calabash::Cucumber::Launcher: Launch Method instruments
Log file: /var/folders/n8/f98qq7wj6sbb_9906hrc8214n1s52y/T/run_loop20140808-99372-1luzwe4/run_loop.out
irb(main):013:0> server_version
{
"outcome" => "SUCCESS",
"app_id" => "*****************",
"simulator_device" => "",
"version" => "0.9.169",
"app_name" => "5.0-42",
"iphone_app_emulated_on_ipad" => false,
"4inch" => false,
"git" => {
"remote_origin" => "git@github.com:calabash/calabash-ios-server.git",
"branch" => "master",
"revision" => "ca62f6e"
},
"app_version" => "5.0",
"iOS_version" => "7.1.1",
"system" => "iPad4,4",
"simulator" => ""
}
irb(main):014:0> uia_query :button
JSON::ParserError: A JSON text must at least contain two octets!
and then app crashes.

I tried @JaniJegoroff solution but it doesn't work. Any help is much appreciated.

Thanks

@krukow
Copy link
Contributor

krukow commented Aug 12, 2014

For people experiencing this bug could you please do the following:

run your test suite with environment variable DEBUG=1 and DEBUG_HTTP=1

For example

DEBUG=1 DEBUG_HTTP=1 cucumber

If you manage to reproduce the issue look at the output for something like this: run_loop.out

log_file=/var/folders/j8/g6wblrl552zfjqrsl5p6fd9m0000gn/T/run_loop20140812-98976-1fhi6nl/run_loop.out

now paste the contents of that file in here (or in gist.github.com and send the link)

For example:

➜  TaskyiOS  cat /var/folders/j8/g6wblrl552zfjqrsl5p6fd9m0000gn/T/run_loop20140812-98976-1fhi6nl/run_loop.out
2014-08-12 11:21:52.650 ScriptAgent[99369:2f07] CLTilesManagerClient: initialize, sSharedTilesManagerClient
2014-08-12 11:21:52.650 ScriptAgent[99369:2f07] CLTilesManagerClient: init
2014-08-12 11:21:52.651 ScriptAgent[99369:2f07] CLTilesManagerClient: reconnecting, 0xa04f5e0
2014-08-12 09:21:54 +0000 Default: OUTPUT_JSON:
{"status":"success","value":true,"index":0}
END_OUTPUT
2014-08-12 09:21:54 +0000 Default: ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
2014-08-12 09:21:55 +0000 Default: index 0 is command: uia.tapOffset('{:x 295.5, :y 41}')
2014-08-12 09:21:55 +0000 Debug: target.tapWithOptions({x:"295.5", y:"41"}, )
2014-08-12 09:21:55 +0000 Default: Success: true
2014-08-12 09:21:55 +0000 Default: Write result...
2014-08-12 09:21:55 +0000 Default: Check successful storage...
2014-08-12 09:21:55 +0000 Default: Storage succeeded: 0
2014-08-12 09:21:55 +0000 Default: index 1 is command: uia.tapOffset('{:x 196, :y 120}')
2014-08-12 09:21:55 +0000 Debug: target.tapWithOptions({x:"196", y:"120"}, )
2014-08-12 09:21:55 +0000 Default: Success: true
2014-08-12 09:21:55 +0000 Default: Write result...
2014-08-12 09:21:55 +0000 Default: Check successful storage...
2014-08-12 09:21:55 +0000 Default: Storage succeeded: 1
2014-08-12 09:21:56 +0000 Default: index 2 is command: uia.typeString('Get Milk', '')
2014-08-12 09:21:57 +0000 Debug: target.frontMostApp().keyboard().typeString("Get Milk")
2014-08-12 09:21:59 +0000 Default: Success: [object Object]
2014-08-12 09:21:59 +0000 Default: Write result...
2014-08-12 09:21:59 +0000 Default: Check successful storage...
2014-08-12 09:21:59 +0000 Default: Storage succeeded: 2
2014-08-12 09:21:59 +0000 Default: index 3 is command: uia.tapOffset('{:x 196, :y 164}')
2014-08-12 09:21:59 +0000 Debug: target.tapWithOptions({x:"196", y:"164"}, )
2014-08-12 09:21:59 +0000 Default: Success: true
2014-08-12 09:21:59 +0000 Default: Write result...
2014-08-12 09:21:59 +0000 Default: Check successful storage...
2014-08-12 09:21:59 +0000 Default: Storage succeeded: 3
2014-08-12 09:22:00 +0000 Default: index 4 is command: uia.typeString('Pickup 1 bottle of milk', '')
2014-08-12 09:22:00 +0000 Debug: target.frontMostApp().keyboard().typeString("Pickup 1 bottle of milk")
2014-08-12 09:22:03 +0000 Default: Success: [object Object]
2014-08-12 09:22:03 +0000 Default: Write result...
2014-08-12 09:22:03 +0000 Default: Check successful storage...
2014-08-12 09:22:03 +0000 Default: Storage succeeded: 4
2014-08-12 09:22:06 +0000 Default: index 5 is command: uia.tapOffset('{:x 160, :y 223}')
2014-08-12 09:22:06 +0000 Debug: target.tapWithOptions({x:"160", y:"223"}, )
2014-08-12 09:22:06 +0000 Default: Success: true
2014-08-12 09:22:06 +0000 Default: Write result...
2014-08-12 09:22:06 +0000 Default: Check successful storage...
2014-08-12 09:22:06 +0000 Default: Storage succeeded: 5
2014-08-12 09:22:08 +0000 Fail: The target application appears to have died
Instruments Trace Complete (Duration : 23.998682s; Output : /var/folders/j8/g6wblrl552zfjqrsl5p6fd9m0000gn/T/run_loop20140812-98976-1fhi6nl/trace.trace)

@krukow krukow reopened this Aug 12, 2014
@jmoody
Copy link
Contributor Author

jmoody commented Aug 12, 2014

@krukow Should we update the http method to catch invalid JSON and throw a meaningful error instead?

@azelder
Copy link

azelder commented Aug 12, 2014

@jmoody @krukow
It looks like in my particular case this issue was the number of views in the view hierarchy. Our app is lazily creating additional cells in a collectionView that was behind the sign in text field. Normally only a few of these cells exist in memory at a given time as the user scrolls to them. It looks like while Calabash was walking the view hierarchy it was touching (and creating) those cells. There were too many cells to all be held in memory this way so the app was crashing with a memory overflow error. Since Calabash had not finished walking the hierarchy when the crash happened the http method was failing and returning nil.

@jmoody
Copy link
Contributor Author

jmoody commented Aug 12, 2014

@krukow We've seen this before. :(

@tomquist
Copy link

As previously said, I get the two errors

Connection refused - connect(2) (http://localhost:37265) (Errno::ECONNREFUSED)

and

a JSON text must at least contain two octets!

on random tests and they alternate randomly.

I ran the test using DEBUG=1 DEBUG_HTTP=1 but currently I only get the connection refused error which produces the following log:

2014-08-13 09:43:09.653 ScriptAgent[89351:2f07] CLTilesManagerClient: initialize, sSharedTilesManagerClient
2014-08-13 09:43:09.654 ScriptAgent[89351:2f07] CLTilesManagerClient: init
2014-08-13 09:43:09.654 ScriptAgent[89351:2f07] CLTilesManagerClient: reconnecting, 0xab24620
2014-08-13 07:43:10 +0000 Default: OUTPUT_JSON:
{"status":"success","value":true,"index":0}
END_OUTPUT
2014-08-13 07:43:10 +0000 Default: ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
2014-08-13 07:43:11 +0000 Default: index 0 is command: uia.tapOffset('{:x 260, :y 30}')
2014-08-13 07:43:11 +0000 Debug: target.tapWithOptions({x:"260", y:"30"}, )
2014-08-13 07:43:11 +0000 Default: Success: true
2014-08-13 07:43:11 +0000 Default: Write result...
2014-08-13 07:43:11 +0000 Default: Check successful storage...
2014-08-13 07:43:11 +0000 Default: Storage succeeded: 0
2014-08-13 07:43:15 +0000 Default: index 1 is command: uia.tapOffset('{:x 80, :y 116}')
2014-08-13 07:43:15 +0000 Debug: target.tapWithOptions({x:"80", y:"116"}, )
2014-08-13 07:43:15 +0000 Default: Success: true
2014-08-13 07:43:15 +0000 Default: Write result...
2014-08-13 07:43:15 +0000 Default: Check successful storage...
2014-08-13 07:43:15 +0000 Default: Storage succeeded: 1
2014-08-13 07:43:15 +0000 Fail: The target application appears to have died
2014-08-13 07:43:15 +0000 Default: OUTPUT_JSON:
{"output":"Unable to read preferences...TypeError: '[object UIAElementNil]' is not a function (evaluating 'target.frontMostApp().preferencesValueForKey(__calabashRequest)')","last_index":1}
END_OUTPUT
Instruments Trace Complete (Duration : 11.183943s; Output : /var/folders/lb/2_mt0hhn3sg3mh4hwccnmjlc0000gn/T/run_loop20140813-83065-19l11mr/trace.trace)

In my console I also found crash-logs for ScriptAgent and launchd_sim.
The process ScriptAgent crashed with

Dispatch queue: CFPreferences Background Sync Queue

and the process launchd_sim crashed with the following message:

Bug in libxpc: Attempt to re-enter the server layer.  Dispatch queue: com.apple.main-thread

As soon as I get the other error, I will post the corresponding log output here.

@jmoody
Copy link
Contributor Author

jmoody commented Aug 13, 2014

Good trace!

TypeError: '[object UIAElementNil]'

@krukow Is it possible that this is related to: UIAKeyboard.typeString() cannot set value on invalid element: UIATextField? [1]

@tomquist
Copy link

Here's another logfile after getting the error a JSON text must at least contain two octets!. Looks similar to my previous log to me:

2014-08-16 03:17:47.412 ScriptAgent[26012:2e07] CLTilesManagerClient: initialize, sSharedTilesManagerClient
2014-08-16 03:17:47.412 ScriptAgent[26012:2e07] CLTilesManagerClient: init
2014-08-16 03:17:47.413 ScriptAgent[26012:2e07] CLTilesManagerClient: reconnecting, 0xa85c760
2014-08-16 01:17:48 +0000 Default: OUTPUT_JSON:
{"status":"success","value":true,"index":0}
END_OUTPUT
2014-08-16 01:17:48 +0000 Default: ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
2014-08-16 01:17:49 +0000 Default: index 0 is command: uia.tapOffset('{:x 260, :y 30}')
2014-08-16 01:17:49 +0000 Debug: target.tapWithOptions({x:"260", y:"30"}, )
2014-08-16 01:17:49 +0000 Default: Success: true
2014-08-16 01:17:49 +0000 Default: Write result...
2014-08-16 01:17:49 +0000 Default: Check successful storage...
2014-08-16 01:17:49 +0000 Default: Storage succeeded: 0
2014-08-16 01:17:53 +0000 Default: index 1 is command: uia.tapOffset('{:x 80, :y 116}')
2014-08-16 01:17:53 +0000 Debug: target.tapWithOptions({x:"80", y:"116"}, )
2014-08-16 01:17:53 +0000 Default: Success: true
2014-08-16 01:17:53 +0000 Default: Write result...
2014-08-16 01:17:53 +0000 Fail: The target application appears to have died
2014-08-16 01:17:53 +0000 Error: Script threw an uncaught JavaScript error: '[object UIAElementNil]' is not a function (evaluating 'target.frontMostApp().setPreferencesValueForKey(sanitized, __calabashResponse)') on line 312 of _run_loop.js
2014-08-16 01:17:53 +0000 Default: OUTPUT_JSON:
{"output":{"output":"Failure: TypeError: '[object UIAElementNil]' is not a function (evaluating 'target.frontMostApp().setPreferencesValueForKey(sanitized, __calabashResponse)')  _response@file://localhost/Users/jenkins/.jenkins/jobs/.../_run_loop.js:312:60\n_success@file://localhost/Users/jenkins/.jenkins/jobs/.../_run_loop.js:328:18\nglobal code@file://localhost/Users/jenkins/.jenkins/jobs/.../_run_loop.js:369:21"},"last_index":1}
END_OUTPUT
2014-08-16 01:17:53 +0000 Default: ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
2014-08-16 01:17:53 +0000 Default: Write result...
Instruments Trace Complete (Duration : 11.298499s; Output : /var/folders/lb/2_mt0hhn3sg3mh4hwccnmjlc0000gn/T/run_loop20140816-22435-no5flv/trace.trace)

@mlberkow
Copy link

I get this error when trying a touch action on a TableViewCell

2014-08-18 20:47:57 +0000 Default: index 0 is command: uia.tapOffset('{:x 160.5, :y 523}')
2014-08-18 20:47:57 +0000 Debug: target.tapWithOptions({x:"160.5", y:"523"}, )
2014-08-18 20:47:57 +0000 Default: Success: true
2014-08-18 20:47:57 +0000 Default: Write result...
2014-08-18 20:47:57 +0000 Default: Check successful storage...
2014-08-18 20:47:57 +0000 Default: Storage succeeded: 0
2014-08-18 20:47:58 +0000 Default: index 1 is command: uia.tapOffset('{:x 87.5, :y 468}')
2014-08-18 20:47:58 +0000 Debug: target.tapWithOptions({x:"87.5", y:"468"}, )
2014-08-18 20:47:58 +0000 Default: Success: true
2014-08-18 20:47:58 +0000 Default: Write result...
2014-08-18 20:47:58 +0000 Default: Check successful storage...
2014-08-18 20:47:58 +0000 Default: Storage succeeded: 1
2014-08-18 20:48:00 +0000 Default: index 2 is command: uia.tapOffset('{:x 170, :y 167}')
2014-08-18 20:48:00 +0000 Debug: target.tapWithOptions({x:"170", y:"167"}, )
2014-08-18 20:48:00 +0000 Default: Success: true
2014-08-18 20:48:00 +0000 Default: Write result...
2014-08-18 20:48:00 +0000 Default: Check successful storage...
2014-08-18 20:48:00 +0000 Default: Storage succeeded: 2
2014-08-18 20:48:00 +0000 Default: index 3 is command: uia.typeString('qa+noins@itriagehealth.com', '')
2014-08-18 20:48:00 +0000 Debug: target.frontMostApp().keyboard().typeString("qa+noins@itriagehealth.com")
2014-08-18 20:48:04 +0000 Default: Success: [object Object]
2014-08-18 20:48:04 +0000 Default: Write result...
2014-08-18 20:48:04 +0000 Default: Check successful storage...
2014-08-18 20:48:04 +0000 Default: Storage succeeded: 3
2014-08-18 20:48:04 +0000 Default: index 4 is command: uia.tapOffset('{:x 170, :y 211}')
2014-08-18 20:48:04 +0000 Debug: target.tapWithOptions({x:"170", y:"211"}, )
2014-08-18 20:48:04 +0000 Default: Success: true
2014-08-18 20:48:04 +0000 Default: Write result...
2014-08-18 20:48:04 +0000 Default: Check successful storage...
2014-08-18 20:48:04 +0000 Default: Storage succeeded: 4
2014-08-18 20:48:05 +0000 Default: index 5 is command: uia.typeString('Tester01', '')
2014-08-18 20:48:05 +0000 Debug: target.frontMostApp().keyboard().typeString("Tester01")
2014-08-18 20:48:06 +0000 Default: Success: [object Object]
2014-08-18 20:48:06 +0000 Default: Write result...
2014-08-18 20:48:06 +0000 Default: Check successful storage...
2014-08-18 20:48:06 +0000 Default: Storage succeeded: 5
2014-08-18 20:48:07 +0000 Default: index 6 is command: uia.tapOffset('{:x 160, :y 263}')
2014-08-18 20:48:07 +0000 Debug: target.tapWithOptions({x:"160", y:"263"}, )
2014-08-18 20:48:07 +0000 Default: Success: true
2014-08-18 20:48:07 +0000 Default: Write result...
2014-08-18 20:48:07 +0000 Default: Check successful storage...
2014-08-18 20:48:07 +0000 Default: Storage succeeded: 6
2014-08-18 14:48:11.455 ScriptAgent[33292:3107] -[ScriptAgent handleAlert:]: script status is 2
2014-08-18 14:48:11.455 ScriptAgent[33292:3107] -[ScriptAgent handleAlert:]: Calling onAlert
2014-08-18 14:48:11.458 ScriptAgent[33292:3107] -[ScriptAgent handleAlert:]: Call to onAlert returned 'YES'
2014-08-18 20:48:11 +0000 Default: OUTPUT_JSON:
{"output":{"output":"on alert"},"last_index":6}
END_OUTPUT

2014-08-18 20:48:11 +0000 Default: index 7 is command: uia.tapOffset('{:x 92.5, :y 322.75}')
2014-08-18 20:48:11 +0000 Debug: target.tapWithOptions({x:"92.5", y:"322.75"}, )
2014-08-18 20:48:11 +0000 Default: Success: true
2014-08-18 20:48:11 +0000 Default: Write result...
2014-08-18 20:48:11 +0000 Default: Check successful storage...
2014-08-18 20:48:11 +0000 Default: Storage succeeded: 7
2014-08-18 20:48:13 +0000 Default: index 8 is command: uia.tapOffset('{:x 51, :y 451}')
2014-08-18 20:48:13 +0000 Debug: target.tapWithOptions({x:"51", y:"451"}, )
2014-08-18 20:48:13 +0000 Default: Success: true
2014-08-18 20:48:13 +0000 Default: Write result...
2014-08-18 20:48:13 +0000 Default: Check successful storage...
2014-08-18 20:48:13 +0000 Default: Storage succeeded: 8
2014-08-18 20:48:14 +0000 Default: index 9 is command: uia.tapOffset('{:x 160, :y 141}')
2014-08-18 20:48:14 +0000 Debug: target.tapWithOptions({x:"160", y:"141"}, )
2014-08-18 20:48:14 +0000 Default: Success: true
2014-08-18 20:48:14 +0000 Default: Write result...
2014-08-18 20:48:14 +0000 Default: Check successful storage...
2014-08-18 20:48:14 +0000 Default: Storage succeeded: 9
2014-08-18 20:48:14 +0000 Fail: The target application appears to have died
Instruments Trace Complete (Duration : 24.168238s; Output : /var/folders/1n/cx0rp3697d37t50zrk9tr7w00000gn/T/run_loop20140818-32953-53mvbc/trace.trace)

@jonaswisplinghoff
Copy link

I went into the same bug with the Error A JSON text must at least contain two octets!. Here's the logfile:

2014-08-25 16:58:42.661 ScriptAgent[74762:2f07] CLTilesManagerClient: initialize, sSharedTilesManagerClient
2014-08-25 16:58:42.662 ScriptAgent[74762:2f07] CLTilesManagerClient: init
2014-08-25 16:58:42.663 ScriptAgent[74762:2f07] CLTilesManagerClient: reconnecting, 0x9f91c10
2014-08-25 14:58:44 +0000 Default: OUTPUT_JSON:
{"status":"success","value":true,"index":0}
END_OUTPUT
2014-08-25 14:58:44 +0000 Default: ****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
2014-08-25 14:58:50 +0000 Default: index 0 is command: uia.tapOffset('{:x 160, :y 402.5}')
2014-08-25 14:58:50 +0000 Debug: target.tapWithOptions({x:"160", y:"402.5"}, )
2014-08-25 14:58:50 +0000 Default: Success: true
2014-08-25 14:58:50 +0000 Default: Write result...
2014-08-25 14:58:50 +0000 Default: Check successful storage...
2014-08-25 14:58:50 +0000 Default: Storage succeeded: 0
2014-08-25 14:58:59 +0000 Default: index 1 is command: uia.tapOffset('{:x 96, :y 544}')
2014-08-25 14:58:59 +0000 Debug: target.tapWithOptions({x:"96", y:"544"}, )
2014-08-25 14:58:59 +0000 Default: Success: true
2014-08-25 14:58:59 +0000 Default: Write result...
2014-08-25 14:58:59 +0000 Default: Check successful storage...
2014-08-25 14:58:59 +0000 Default: Storage succeeded: 1
2014-08-25 14:59:00 +0000 Fail: The target application appears to have died
Instruments Trace Complete (Duration : 29.265829s; Output : /var/folders/k5/6581dbtn28gf57grp40ljxx40000gn/T/run_loop20140825-74614-1cmckl1/trace.trace)

@paulb00th
Copy link

We're also getting a lot of intermittent 'ECONNREFUSED' and 'two octets' errors. Here is a log of a 'two octets' error

2014-09-04 21:21:00 +0000 Default: index 0 is command: uia.tapOffset('{:x 224, :y 544}')
2014-09-04 21:21:00 +0000 Fail: The target application appears to have died
2014-09-04 21:21:00 +0000 Error: Script threw an uncaught JavaScript error: '[object UIAElementNil]' is not a function (evaluating 'target.frontMostApp().setPreferencesValueForKey(null, __calabashRequest)') on line 361 of _run_loop.js
Instruments Trace Complete (Duration : 11.810826s; Output : /var/folders/24/b1hqsvz52d95330pj5kj598m0000gn/T/run_loop20140904-53214-8jqkht/trace.trace)

@paulb00th
Copy link

Here is a log of the 'ECONNREFUSED' error:

2014-09-16 11:48:22.463 ScriptAgent[31568:3007] CLTilesManagerClient: initialize, sSharedTilesManagerClient
2014-09-16 11:48:22.464 ScriptAgent[31568:3007] CLTilesManagerClient: init
2014-09-16 11:48:22.464 ScriptAgent[31568:3007] CLTilesManagerClient: reconnecting, 0xda15f20
2014-09-16 10:48:23 +0000 Default: OUTPUT_JSON:
{"status":"success","value":true,"index":0}
END_OUTPUT
2014-09-16 10:48:23 +0000 Default: *************** LOTS_OF_ASTERISKS_REMOVED *************
2014-09-16 10:48:24 +0000 Fail: The target application appears to have died
2014-09-16 10:48:24 +0000 Default: OUTPUT_JSON:
{"output":"Unable to read preferences...TypeError: '[object UIAElementNil]' is not a function (evaluating 'target.frontMostApp().preferencesValueForKey(__calabashRequest)')","last_index":0}
END_OUTPUT
Instruments Trace Complete (Duration : 12.002614s; Output : /var/folders/24/b1hqsvz52d95330pj5kj598m0000gn/T/run_loop20140916-24687-xp1h7b/trace.trace)

@Foovanadil
Copy link

Just upgraded to Calabash 10.1 and am now getting this two octets error for every test in my test suite. Here is the DEBUG log for one particular feature

At the end of the trace I see a 200 OK coming back from the uia tap offset call but with no message body (presumably you are expecting JSON data here and failing to parse it, hence the error)?

Any workarounds to get my tests running again?

DEBUG=1 DEBUG_HTTP=1 cucumber -p ios -v features/login.feature:4
Code:

  • features/support/env.rb
  • features/ios/01_launch.rb
  • features/ios/base_page.rb
  • features/pages/complete_delivery_page.rb
  • features/pages/current_load_page.rb
  • features/pages/damage_area_page.rb
  • features/pages/damage_location_page.rb
  • features/pages/damage_severity_page.rb
  • features/pages/damage_type_page.rb
  • features/pages/delivery_conditions_page.rb
  • features/pages/delivery_damages_page.rb
  • features/pages/inspection_page.rb
  • features/pages/login_page.rb
  • features/pages/manage_delivery_page.rb
  • features/pages/manage_load_page.rb
  • features/pages/manage_pickup_page.rb
  • features/pages/select_load_page.rb
  • features/pages/select_vehicle_page.rb
  • features/pages/unload_page.rb
  • features/step_definitions/current_load_steps.rb
  • features/step_definitions/enter_damage.steps.rb
  • features/step_definitions/login_steps.rb
  • features/step_definitions/manage_pickup.steps.rb
  • features/step_definitions/unload_steps.rb

Features:

  • features/login.feature:4
    Parsing feature files took 0m0.004s

Using the ios profile...
Feature: Login to m.transport app
As a driver I want to login to the m.transport application

Scenario: Login with a valid username and password # features/login.feature:4

INFO: Using uia strategy: 'preferences'
Preparation took 2.353984 seconds
{
:app => "/Users/Brad/Code/m.transport/src/m.transport/Core.Tests/calabash_tests/mtransportiOS.app",
:args => [],
:bundle_dir_or_bundle_id => "/Users/Brad/Code/m.transport/src/m.transport/Core.Tests/calabash_tests/mtransportiOS.app",
:bundle_id => "com.mophilly.mtransport",
:device => "iphone",
:device_target => "simulator",
:launch_method => :instruments,
:launch_retries => 5,
:log_file => "/var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k/run_loop.out",
:no_launch => false,
:no_stop => false,
:reset => false,
:results_dir => "/var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k",
:results_dir_trace => "/var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k/trace",
:script => "/var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k/_run_loop.js",
:sdk_version => nil,
:udid => "iPhone 5 (8.0 Simulator)",
:uia_strategy => :preferences,
:xcode => "6.0.1",
:xcode_path => "/Applications/Xcode.app/Contents/Developer"
}

Starting on simulator App: /Users/Brad/Code/m.transport/src/m.transport/Core.Tests/calabash_tests/mtransportiOS.app

2014-09-23 12:57:20 -0700 xcrun instruments -w "iPhone 5 (8.0 Simulator)" -D "/var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k/trace" -t "Automation" "/Users/Brad/Code/m.transport/src/m.transport/Core.Tests/calabash_tests/mtransportiOS.app" -e UIARESULTSPATH /var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k -e UIASCRIPT /var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k/_run_loop.js &> /var/folders/_y/3l50pv116tddjltlpw1lqwz40000gn/T/run_loop20140923-7468-1f9gd2k/run_loop.out
Launching took 4.34569 seconds
= Request

! CONNECT TO localhost:37265
! CONNECTION ESTABLISHED
POST /map HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.3.4.1, ruby 2.0.0 (2014-02-24))
Accept: /
Date: Tue, 23 Sep 2014 19:57:24 GMT
Content-Length: 82
Host: localhost:37265

{"query":"* marked:'username'","operation":{"method_name":"query","arguments":[]}}

= Response

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 435
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Date: Tue, 23 Sep 2014 19:57:24 GMT
Accept-Ranges: bytes
Access-Control-Max-Age: 3000

{"status_bar_orientation":"down","results":[{"text":"","rect":{"center_x":160,"y":114,"width":280,"x":20,"center_y":129,"height":30},"description":"<UITextField: 0x7eccb220; frame = (0 0; 280 30); text = ''; clipsToBounds = YES; opaque = NO; gestureRecognizers = <NSArray: 0x7f8a08b0>; layer = <CALayer: 0x7ecca360>>","id":"username","label":"","class":"UITextField","frame":{"y":0,"width":280,"x":0,"height":30}}],"outcome":"SUCCESS"} Given I am not logged in # features/step_definitions/login_steps.rb:1
= Request

POST /map HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.3.4.1, ruby 2.0.0 (2014-02-24))
Accept: /
Date: Tue, 23 Sep 2014 19:57:25 GMT
Content-Length: 86
Host: localhost:37265

{"query":"* marked:'username'","operation":{"method_name":"setText","arguments":[""]}}

= Response

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 236
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Date: Tue, 23 Sep 2014 19:57:25 GMT
Accept-Ranges: bytes
Access-Control-Max-Age: 3000

{"status_bar_orientation":"down","results":["<UITextField: 0x7eccb220; frame = (0 0; 280 30); text = ''; clipsToBounds = YES; opaque = NO; gestureRecognizers = <NSArray: 0x7f8a08b0>; layer = <CALayer: 0x7ecca360>>"],"outcome":"SUCCESS"}= Request

POST /map HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.3.4.1, ruby 2.0.0 (2014-02-24))
Accept: /
Date: Tue, 23 Sep 2014 19:57:25 GMT
Content-Length: 82
Host: localhost:37265

{"query":"* marked:'username'","operation":{"method_name":"query","arguments":[]}}

= Response

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Length: 435
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Date: Tue, 23 Sep 2014 19:57:25 GMT
Accept-Ranges: bytes
Access-Control-Max-Age: 3000

{"status_bar_orientation":"down","results":[{"text":"","rect":{"center_x":160,"y":114,"width":280,"x":20,"center_y":129,"height":30},"description":"<UITextField: 0x7eccb220; frame = (0 0; 280 30); text = ''; clipsToBounds = YES; opaque = NO; gestureRecognizers = <NSArray: 0x7f8a08b0>; layer = <CALayer: 0x7ecca360>>","id":"username","label":"","class":"UITextField","frame":{"y":0,"width":280,"x":0,"height":30}}],"outcome":"SUCCESS"}Sending UIA command
uia.tapOffset('{:x 160, :y 129}')
= Request

POST /uia HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.3.4.1, ruby 2.0.0 (2014-02-24))
Accept: /
Date: Tue, 23 Sep 2014 19:57:25 GMT
Content-Length: 47
Host: localhost:37265

{"command":"uia.tapOffset('{:x 160, :y 129}')"}

= Response

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Accept-Ranges: bytes
Date: Tue, 23 Sep 2014 19:57:25 GMT

! CONNECTION CLOSED
When I enter a valid username # features/step_definitions/login_steps.rb:5
A JSON text must at least contain two octets! (JSON::ParserError)
./features/ios/base_page.rb:6:in enter_text' ./features/pages/login_page.rb:9:inenter_username'
./features/step_definitions/login_steps.rb:6:in /^I enter a valid username$/' features/login.feature:6:inWhen I enter a valid username'
And I enter a valid password # features/step_definitions/login_steps.rb:9
And I enter a valid truck # features/step_definitions/login_steps.rb:13
And I tap login # features/step_definitions/login_steps.rb:17
Then I should see the current run screen # features/step_definitions/login_steps.rb:33
= Request

= Request

! CONNECT TO localhost:37265
Sending 'QUIT' to instruments process '7671'

Failing Scenarios:
cucumber -p ios features/login.feature:4 # Scenario: Login with a valid username and password

1 scenario (1 failed)
6 steps (1 failed, 4 skipped, 1 passed)
0m9.335s

@sychoeatclub
Copy link

I am having a same issue with Foovanadil. I get 200 OK for uia.tapOffset request, but it does not proceed after that.

@jmoody
Copy link
Contributor Author

jmoody commented Nov 13, 2014

@jmoody
Copy link
Contributor Author

jmoody commented Nov 13, 2014

I have updated the gem to report this as a possible application crash.

If folks are still experiencing this in Xcode 6.1, please look for a crash report and include it here.

@krukow
Copy link
Contributor

krukow commented Nov 14, 2014

@jmoody it is not clear to me if this can be closed?

@sychoeatclub
Copy link

Thanks @jmoody It looks like my problem is fixed now. The touch gestures are not having timeouts anymore.

@jmoody
Copy link
Contributor Author

jmoody commented Nov 17, 2014

@krukow I think it makes sense to close this issue because the title no longer describes the error message that appears.

@mvemjsun
Copy link

I am getting the same error on iOS 9.0, calabash 0.14.3, Xcode 6.3

The app launches then stops . Interesting that it happens only in landscape mode. My Cucumber step does is very simple which at the moment does not have any calabash code in it.

2015-09-21 16:52:38 +0100 [RunLoop:debug]: 
{
                        :app => "/Users/pte05/nowtv-ios-tests/nowtv-ios/POUPI/Applications/NOWTV-CAL.app",
                       :args => [],
    :bundle_dir_or_bundle_id => "com.****",
                  :bundle_id => "com.***",
                     :device => "ipad",
              :device_target => "4353ffedefed372c4d757039097da317a*****",
              :launch_method => :instruments,
             :launch_retries => 5,
                   :log_file => "/var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv/run_loop.out",
                  :no_launch => false,
                    :no_stop => false,
         :relaunch_simulator => true,
                      :reset => false,
                :results_dir => "/var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv",
          :results_dir_trace => "/var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv/trace",
                     :script => "/var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv/_run_loop.js",
                :sdk_version => nil,
                       :udid => "4353ffedefed372c4d757039097da317a17*****",
               :uia_strategy => :host,
                      :xcode => "6.3",
                 :xcode_path => "/Applications/Xcode.app/Contents/Developer"
}

### Starting on 4353ffedefed372c4d757039097da317a177f61a App: com.*** ###
2015-09-21 16:52:38 +0100 [RunLoop:debug]: xcrun instruments -w 4353ffedefed372c4d757039097da317a177f61a -D /var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv/trace -t Automation com.*** -e UIARESULTSPATH /var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv -e UIASCRIPT /var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv/_run_loop.js >& /var/folders/25/9_sb609576jcmgdbqt553ps08n5b5c/T/run_loop20150921-27662-7adckv/run_loop.out
2015-09-21 16:52:38 +0100 [RunLoop:debug]: Preparation took 0.559977 seconds
2015-09-21 16:52:42 +0100 [RunLoop:debug]: Launching took 4.06362 seconds
= Request

! CONNECT TO 127.0.1.1:37265
! CONNECTION ESTABLISHED
POST /map HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.6.0.1, ruby 1.9.3 (2013-06-27))
Accept: */*
Date: Mon, 21 Sep 2015 15:52:42 GMT
Content-Length: 83
Host: 127.0.1.1:37265

{"query":null,"operation":{"method_name":"orientation","arguments":["status_bar"]}}

= Response

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Max-Age: 3000
Accept-Ranges: bytes
Date: Mon, 21 Sep 2015 15:52:19 GMT
Content-Length: 74
Access-Control-Allow-Origin: *

{"status_bar_orientation":"right","results":["right"],"outcome":"SUCCESS"}= Request

POST /map HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.6.0.1, ruby 1.9.3 (2013-06-27))
Accept: */*
Date: Mon, 21 Sep 2015 15:52:42 GMT
Content-Length: 83
Host: 127.0.1.1:37265

{"query":null,"operation":{"method_name":"orientation","arguments":["status_bar"]}}

= Response

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Max-Age: 3000
Accept-Ranges: bytes
Date: Mon, 21 Sep 2015 15:52:19 GMT
Content-Length: 74
Access-Control-Allow-Origin: *

{"status_bar_orientation":"right","results":["right"],"outcome":"SUCCESS"}= Request

POST /map HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.6.0.1, ruby 1.9.3 (2013-06-27))
Accept: */*
Date: Mon, 21 Sep 2015 15:52:42 GMT
Content-Length: 83
Host: 127.0.1.1:37265

{"query":null,"operation":{"method_name":"orientation","arguments":["status_bar"]}}

= Response

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Max-Age: 3000
Accept-Ranges: bytes
Date: Mon, 21 Sep 2015 15:52:19 GMT
Content-Length: 74
Access-Control-Allow-Origin: *

{"status_bar_orientation":"right","results":["right"],"outcome":"SUCCESS"}= Request

POST /play HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: HTTPClient/1.0 (2.6.0.1, ruby 1.9.3 (2013-06-27))
Accept: */*
Date: Mon, 21 Sep 2015 15:52:42 GMT
Content-Length: 135
Host: 127.0.1.1:37265

{"events":"YnBsaXN0MDChAdMCBAYDBQdURGF0YUQCAAAAoFRUaW1lEwAAAbpMnOcWVFR5cGUQ
MggKERYcISovAAAAAAAAAQEAAAAAAAAACAAAAAAAAAAAAAAAAAAAADE=
"}

= Response

HTTP/1.1 200 OK
Date: Mon, 21 Sep 2015 15:52:19 GMT
Accept-Ranges: bytes
Transfer-Encoding: chunked

! CONNECTION CLOSED

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

@jmoody
Copy link
Contributor Author

jmoody commented Sep 21, 2015

I am getting the same error on iOS 9.0, calabash 0.14.3, Xcode 6.3

This does not seem like a valid configuration. iOS 9.0 on Xcode 6.3?

Please open a new issue, this one has been resolved.

If you are not using Xcode 7, the most recent version of Calabash (0.16.3) and run-loop (1.5.4), please update. If Xcode 7 is not an option, update your Calabash and run-loop versions.

https://github.com/calabash/calabash-ios/wiki#reporting-problems

If the app is crashing, please provide a crash log file.

@mvemjsun
Copy link

Thanks @jmoody I will fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests