Skip to content
This repository has been archived by the owner on Dec 26, 2019. It is now read-only.

Long application start when creating a session with shouldWaitForQuiescence=false on Xcode 10 #993

Open
fr0l opened this issue Sep 19, 2018 · 10 comments

Comments

@fr0l
Copy link
Contributor

fr0l commented Sep 19, 2018

On Xcode 10 with simulators iOS 11.4 and iOS 12
when creating a WebDriver session with desired capability shouldWaitForQuiescence = false
(or if not setting the capability, it defaults to false(in objc code - NO))
then it takes approximately one minute at application launch - i.e. before the method FBApplication.launch returns.

Example of desired capabilities

{
  "bundleId": "MyCoolApp",
  "shouldWaitForQuiescence": false // or 'shouldWaitForQuiescence' not present
}

When setting shouldWaitForQuiescence = true or effectively equal - commenting out the whole if block in FBApplication.launch
then the FBApplication.launch returns within 5-6 seconds.

Below is the part of code in FBApplication.m where the method [super launch]; (XCTest framework method) meditates for one minute (but only in case if the addObserver:self was executed).

- (void)launch
{
  if (!self.fb_shouldWaitForQuiescence) {
    [self.fb_appImpl addObserver:self forKeyPath:FBStringify(XCUIApplicationImpl, currentProcess) options:(NSKeyValueObservingOptions)(NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew) context:nil];
    self.fb_isObservingAppImplCurrentProcess = YES;
  }
  [super launch];
  [FBApplication fb_registerApplication:self withProcessID:self.processID];
}

As a workaround - creating WebDriver session with capabilities

{
  "bundleId": "MyCoolApp",
  "shouldWaitForQuiescence": true
}

If I remember correctly, this behaviour is observed since Xcode 10 beta 5

@jamesvanhorn
Copy link

I am also seeing this issue in the version of WebDriverAgent packaged with Appium 1.9.0. In Appium 1.9.1 waitForQuiescence=false is broken. Stack trace:

-[NSProxy forwardInvocation:] called!
[MJSONWP] 
[MJSONWP] (
[MJSONWP] 	0   CoreFoundation                      0x000000010d16e29b __exceptionPreprocess + 331
[MJSONWP] 	1   libobjc.A.dylib                     0x000000010c70a735 objc_exception_throw + 48
[MJSONWP] 	2   CoreFoundation                      0x000000010d16e0f5 +[NSException raise:format:] + 197
[MJSONWP] 	3   Foundation                          0x000000010c18d8fe -[NSProxy respondsToSelector:] + 95
[MJSONWP] 	4   Foundation                          0x000000010c1a0813 _NSDescriptionWithStringProxyFunc + 49
[MJSONWP] 	5   CoreFoundation                      0x000000010d0f71ab __CFStringAppendFormatCore + 15227
[MJSONWP] 	6   CoreFoundation                      0x000000010d0f8237 _CFStringCreateWithFormatAndArgumentsAux2 + 119
[MJSONWP] 	7   XCTest                              0x000000010bfb9a1f _XCINFLog + 237
[MJSONWP] 	8   XCTest                              0x000000010bfe9369 -[XCUIApplicationImpl setCurrentProcess:] + 68
[MJSONWP] 	9   Foundation                          0x000000010c1370b4 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
[MJSONWP] 	10  WebDriverAgentLib                   0x0000000123f162d6 -[FBApplication observeValueForKeyPath:ofObject:change:context:] + 566
[MJSONWP] 	11  Foundation                          0x000000010c1482bb NSKeyValueNotifyObserver + 332
[MJSONWP] 	12  Foundation                          0x000000010c147f4e -[NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] + 255
[MJSONWP] 	13  Foundation                          0x000000010c148662 -[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] + 103
[MJSONWP] 	14  WebDriverAgentLib                   0x0000000123f15dbd -[FBApplication launch] + 157
[MJSONWP] 	15  WebDriverAgentLib                   0x0000000123f039dd +[FBSessionCommands handleCreateSession:] + 1565
[MJSONWP] 	16  WebDriverAgentLib                   0x0000000123edbf26 -[FBRoute_TargetAction mountRequest:intoResponse:] + 182
[MJSONWP] 	17  WebDriverAgentLib                   0x0000000123ec9269 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 553
[MJSONWP] 	18  RoutingHTTPServer                   0x0000000123fbac18 -[RoutingHTTPServer handleRoute:withRequest:response:] + 136
[MJSONWP] 	19  RoutingHTTPServer                   0x0000000123fbb4fa __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 47
[MJSONWP] 	20  libdispatch.dylib                   0x0000000111ca0587 _dispatch_client_callout + 8
[MJSONWP] 	21  libdispatch.dylib                   0x0000000111cad072 _dispatch_async_and_wait_invoke + 109
[MJSONWP] 	22  libdispatch.dylib                   0x0000000111ca0587 _dispatch_client_callout + 8
[MJSONWP] 	23  libdispatch.dylib                   0x0000000111cac3bc _dispatch_main_queue_callback_4CF + 1290
[MJSONWP] 	24  CoreFoundation                      0x000000010d0d17f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
[MJSONWP] 	25  CoreFoundation                      0x000000010d0cbe86 __CFRunLoopRun + 2342
[MJSONWP] 	26  CoreFoundation                      0x000000010d0cb221 CFRunLoopRunSpecific + 625
[MJSONWP] 	27  Foundation                          0x000000010c18f522 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 277
[MJSONWP] 	28  WebDriverAgentLib                   0x0000000123ec7d50 -[FBWebServer startServing] + 368
[MJSONWP] 	29  WebDriverAgentRunner                0x0000000123eb503a -[UITestingUITests testRunner] + 122
[MJSONWP] 	30  CoreFoundation                      0x000000010d17511c __invoking___ + 140
[MJSONWP] 	31  CoreFoundation                      0x000000010d1725b5 -[NSInvocation invoke] + 325
[MJSONWP] 	32  XCTest                              0x000000010bf75b6e __24-[XCTestCase invokeTest]_block_invoke.192 + 78
[MJSONWP] 	33  XCTest                              0x000000010bfcd2e8 -[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
[MJSONWP] 	34  XCTest                              0x000000010bfcd205 -[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
[MJSONWP] 	35  XCTest                              0x000000010bf7582f __24-[XCTestCase invokeTest]_block_invoke + 848
[MJSONWP] 	36  XCTest                              0x000000010bfd31ee -[XCUITestContext performInScope:] + 248
[MJSONWP] 	37  XCTest                              0x000000010bf75424 -[XCTestCase testContextPerformInScope:] + 98
[MJSONWP] 	38  XCTest                              0x000000010bf754d2 -[XCTestCase invokeTest] + 137
[MJSONWP] 	39  XCTest                              0x000000010bf7700d __26-[XCTestCase performTest:]_block_invoke_2 + 43
[MJSONWP] 	40  XCTest                              0x000000010bfcd2e8 -[XCTestCase(Failures) performFailableBlock:testCaseRun:shouldInterruptTest:] + 57
[MJSONWP] 	41  XCTest                              0x000000010bfcd205 -[XCTestCase(Failures) _performTurningExceptionsIntoFailuresInterruptAfterHandling:block:] + 96
[MJSONWP] 	42  XCTest                              0x000000010bf76f24 __26-[XCTestCase performTest:]_block_invoke.326 + 88
[MJSONWP] 	43  XCTest                              0x000000010bfdda3b +[XCTContext runInContextForTestCase:block:] + 225
[MJSONWP] 	44  XCTest                              0x000000010bf76653 -[XCTestCase performTest:] + 675
[MJSONWP] 	45  XCTest                              0x000000010bfb9802 -[XCTest runTest] + 57
[MJSONWP] 	46  XCTest                              0x000000010bf7185b __27-[XCTestSuite performTest:]_block_invoke + 365
[MJSONWP] 	47  XCTest                              0x000000010bf71033 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 55
[MJSONWP] 	48  XCTest                              0x000000010bf712f6 -[XCTestSuite performTest:] + 296
[MJSONWP] 	49  XCTest                              0x000000010bfb9802 -[XCTest runTest] + 57
[MJSONWP] 	50  XCTest                              0x000000010bf7185b __27-[XCTestSuite performTest:]_block_invoke + 365
[MJSONWP] 	51  XCTest                              0x000000010bf71033 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 55
[MJSONWP] 	52  XCTest                              0x000000010bf712f6 -[XCTestSuite performTest:] + 296
[MJSONWP] 	53  XCTest                              0x000000010bfb9802 -[XCTest runTest] + 57
[MJSONWP] 	54  XCTest                              0x000000010bf7185b __27-[XCTestSuite performTest:]_block_invoke + 365
[MJSONWP] 	55  XCTest                              0x000000010bf71033 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 55
[MJSONWP] 	56  XCTest                              0x000000010bf712f6 -[XCTestSuite performTest:] + 296
[MJSONWP] 	57  XCTest                              0x000000010bfb9802 -[XCTest runTest] + 57
[MJSONWP] 	58  XCTest                              0x000000010bfe7ea6 __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke + 171
[MJSONWP] 	59  XCTest                              0x000000010bfe7fc7 __44-[XCTTestRunSession runTestsAndReturnError:]_block_invoke.80 + 68
[MJSONWP] 	60  XCTest                              0x000000010bf8986a -[XCTestObservationCenter _observeTestExecutionForBlock:] + 594
[MJSONWP] 	61  XCTest                              0x000000010bfe7c1a -[XCTTestRunSession runTestsAndReturnError:] + 623
[MJSONWP] 	62  XCTest                              0x000000010bf5625a -[XCTestDriver runTestsAndReturnError:] + 422
[MJSONWP] 	63  XCTest                              0x000000010bfd9fbd _XCTestMain + 1478
[MJSONWP] 	64  WebDriverAgentRunner-Runner         0x000000010bc7502d -[_XCTRunnerAppDelegate applicationWillResignActive:] + 0
[MJSONWP] 	65  WebDriverAgentRunner-Runner         0x000000010bc74f2b _XCTRunnerRunTests + 0
[MJSONWP] 	66  CoreFoundation                      0x000000010d0d1a3c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
[MJSONWP] 	67  CoreFoundation                      0x000000010d0d11f0 __CFRunLoopDoBlocks + 336
[MJSONWP] 	68  CoreFoundation                      0x000000010d0cba64 __CFRunLoopRun + 1284
[MJSONWP] 	69  CoreFoundation                      0x000000010d0cb221 CFRunLoopRunSpecific + 625
[MJSONWP] 	70  GraphicsServices                    0x00000001157cf1dd GSEventRunModal + 62
[MJSONWP] 	71  UIKitCore                           0x000000010db21115 UIApplicationMain + 140
[MJSONWP] 	72  WebDriverAgentRunner-Runner         0x000000010bc751f5 main + 183
[MJSONWP] 	73  libdyld.dylib                       0x0000000111d10551 start + 1
[MJSONWP] 	74  ???                                 0x0000000000000005 0x0 + 5
[MJSONWP] )
[MJSONWP]     at XCUITestDriver.quitAndUninstall$ (/Users/jamesvanhorn/.nvm/versions/node/v10.1.0/lib/node_modules/appium/node_modules/appium-xcuitest-driver/lib/driver.js:444:13)
[MJSONWP]     at tryCatch (/Users/jamesvanhorn/.nvm/versions/node/v10.1.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[MJSONWP]     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/jamesvanhorn/.nvm/versions/node/v10.1.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[MJSONWP]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/jamesvanhorn/.nvm/versions/node/v10.1.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[MJSONWP]     at GeneratorFunctionPrototype.invoke (/Users/jamesvanhorn/.nvm/versions/node/v10.1.0/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)

@fr0l
Copy link
Contributor Author

fr0l commented Sep 21, 2018

@jamesvanhorn this is a bit different bug. the one that you've posted should be fixed by appium#119

@jamesvanhorn
Copy link

thanks for the quick fix

@lanzelot1989
Copy link

Should the desired capability for Appium be

waitForQuiescence
// or
shouldWaitForQuiescence

?

@robin-xl
Copy link

How is it going on? Is there someone can handle this?

@ghost
Copy link

ghost commented Oct 16, 2018

same issue here...
xcode 10
appium 1.9.2-beta.2

everything worked perfect before updating xcode and appium

@harlentan
Copy link

the same issue. +

@jswaroop
Copy link

jswaroop commented Dec 6, 2018

same issue with xcode 10.1 and iOS 12.1.1 and appium 1.10.0 in realdevice.
it takes exactly one minute to launch the test once app is opened or it just keeps opening the app again and again

@jswaroop
Copy link

jswaroop commented Dec 7, 2018

Hey guys i think i found a hacky solution to run automation on iOS 12> in real devices
i copied ios 12sdk in xcode10 to xcode 9
used appium 1.10.0
in the desired capabilities set platformVersion to 11.4 even though its >12
set xcode to version 9 using sudo xcode-select -switch /Applications/Xcode.app/
doing all these i am able to run automation in ios 12.1.1 in realdevice and appium 1.10.0 using xcode9

@lanzelot1989
Copy link

Does anyone have another solution or is @jswaroop downgrade to XCode 9 the way to go?

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

No branches or pull requests

6 participants