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

fix: Prevent freeze on launch/activate of a missing app #706

Merged
merged 1 commit into from
May 16, 2023

Conversation

mykola-mokhnach
Copy link

This is another approach to workaround #702 after the previous one has miserably failed due to real device security restrictions.

Copy link
Member

@KazuCocoa KazuCocoa left a comment

Choose a reason for hiding this comment

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

lgtm, it worked on a real device as well

@KazuCocoa
Copy link
Member

When i gave not installed bundle id:

$ curl -X POST http://192.168.4.24:8100/session/2E9FE934-A41B-469B-AEE9-FAF2D854B5E1/wda/apps/launch -d '{ "bundleId": "com.google.chrome.io" }'
{
  "value" : {
    "error" : "invalid argument",
    "message" : "Error Domain=FBSOpenApplicationServiceErrorDomain Code=4 \"The request to open \"com.google.chrome.io\" failed.\" UserInfo={BSErrorCodeDescription=InvalidRequest, NSLocalizedDescription=The request to open \"com.google.chrome.io\" failed., FBSOpenApplicationRequestID=0x13b9, NSUnderlyingError=0x283546b50 {Error Domain=FBSOpenApplicationErrorDomain Code=4 \"Application info provider (FBSApplicationLibrary) returned nil for \"com.google.chrome.io\"\" UserInfo={BSErrorCodeDescription=NotFound, NSLocalizedFailureReason=Application info provider (FBSApplicationLibrary) returned nil for \"com.google.chrome.io\"}}}",
    "traceback" : "(\n\t0   CoreFoundation                      0x00000001c1ba8cc0 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 40128\n\t1   libobjc.A.dylib                     0x00000001bacc83d0 objc_exception_throw + 60\n\t2   WebDriverAgentLib                   0x00000001095acef0 swizzledLaunchApp + 1244\n\t3   XCUIAutomation                      0x000000010322139c __107-[XCUIPlatformApplicationManager launchProcessWithPath:bundleID:arguments:environmentVariables:completion:]_block_invoke + 164\n\t4   XCTestCore                          0x00000001030619d0 +[XCTFuture futureWithTimeout:description:block:] + 196\n\t5   XCUIAutomation                      0x0000000103221178 -[XCUIPlatformApplicationManager launchProcessWithPath:bundleID:arguments:environmentVariables:completion:] + 376\n\t6   XCUIAutomation                      0x0000000103204a24 __69-[XCUIApplicationImpl _launchUsingPlatformWithArguments:environment:]_block_invoke + 240\n\t7   XCTestCore                          0x00000001030619d0 +[XCTFuture futureWithTimeout:description:block:] + 196\n\t8   XCUIAutomation                      0x0000000103204854 -[XCUIApplicationImpl _launchUsingPlatformWithArguments:environment:] + 204\n\t9   XCUIAutomation                      0x0000000103203a80 __42-[XCUIApplicationImpl _launchWithRequest:]_block_invoke + 732\n\t10  XCTestCore                          0x0000000103089db0 -[XCTContext _runActivityNamed:type:block:] + 208\n\t11  XCTestCore                          0x0000000103088be8 -[XCTContext runInternalActivityNamed:block:] + 152\n\t12  XCUIAutomation                      0x0000000103203758 -[XCUIApplicationImpl _launchWithRequest:] + 252\n\t13  XCTestCore                          0x0000000103089db0 -[XCTContext _runActivityNamed:type:block:] + 208\n\t14  XCTestCore                          0x0000000103088be8 -[XCTContext runInternalActivityNamed:block:] + 152\n\t15  XCUIAutomation                      0x0000000103203148 -[XCUIApplicationImpl serviceOpenRequest:] + 260\n\t16  XCUIAutomation                      0x00000001032196a4 -[XCUIApplication _launchUsingXcode:withoutAccessibility:] + 268\n\t17  WebDriverAgentLib                   0x00000001095aaf88 -[FBApplication launch] + 56\n\t18  WebDriverAgentLib                   0x000000010956b488 -[FBSession launchApplicationWithBundleId:shouldWaitForQuiescence:arguments:environment:] + 432\n\t19  WebDriverAgentLib                   0x0000000109591c68 +[FBSessionCommands handleSessionAppLaunch:] + 312\n\t20  WebDriverAgentLib                   0x0000000109535aa0 -[FBRoute_TargetAction mountRequest:intoResponse:] + 168\n\t21  WebDriverAgentLib                   0x0000000109522698 __37-[FBWebServer registerRouteHandlers:]_block_invoke + 400\n\t22  WebDriverAgentLib                   0x0000000109556cc8 -[RoutingHTTPServer handleRoute:withRequest:response:] + 160\n\t23  WebDriverAgentLib                   0x0000000109557754 __72-[RoutingHTTPServer routeMethod:withPath:parameters:request:connection:]_block_invoke + 64\n\t24  libdispatch.dylib                   0x00000001c906aeac BB347F0E-F21C-3607-82E6-C8D750FDBF8C + 16044\n\t25  libdispatch.dylib                   0x00000001c907a500 BB347F0E-F21C-3607-82E6-C8D750FDBF8C + 79104\n\t26  libdispatch.dylib                   0x00000001c906aeac BB347F0E-F21C-3607-82E6-C8D750FDBF8C + 16044\n\t27  libdispatch.dylib                   0x00000001c90796a4 BB347F0E-F21C-3607-82E6-C8D750FDBF8C + 75428\n\t28  libdispatch.dylib                   0x00000001c90792f4 _dispatch_main_queue_callback_4CF + 44\n\t29  CoreFoundation                      0x00000001c1c37c28 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 625704\n\t30  CoreFoundation                      0x00000001c1c19560 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 501088\n\t31  CoreFoundation                      0x00000001c1c1e3ec CFRunLoopRunSpecific + 612\n\t32  Foundation                          0x00000001bbf1efd4 6E76DC96-11AF-3B2E-B71E-215F9CC6E822 + 270292\n\t33  WebDriverAgentLib                   0x000000010952154c -[FBWebServer startServing] + 328\n\t34  WebDriverAgentRunner                0x000000010551b980 -[UITestingUITests testRunner] + 80\n\t35  CoreFoundation                      0x00000001c1c11c04 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 470020\n\t36  CoreFoundation                      0x00000001c1bbfcb4 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 134324\n\t37  XCTestCore                          0x00000001030b58e8 +[XCTFailableInvocation invokeStandardConventionInvocation:completion:] + 68\n\t38  XCTestCore                          0x00000001030b589c __90+[XCTFailableInvocation invokeInvocation:withTestMethodConvention:lastObservedErrorIssue:]_block_invoke_3 + 28\n\t39  XCTestCore                          0x00000001030b5228 __81+[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:]_block_invoke.5 + 112\n\t40  XCTestCore                          0x0000000103073938 +[XCTSwiftErrorObservation observeErrorsInBlock:] + 148\n\t41  XCTestCore                          0x00000001030b5088 +[XCTFailableInvocation invokeWithAsynchronousWait:lastObservedErrorIssue:block:] + 460\n\t42  XCTestCore                          0x00000001030b55f4 +[XCTFailableInvocation invokeInvocation:withTestMethodConvention:lastObservedErrorIssue:] + 372\n\t43  XCTestCore                          0x00000001030b5970 +[XCTFailableInvocation invokeInvocation:lastObservedErrorIssue:] + 72\n\t44  XCTestCore                          0x00000001030a28c0 __24-[XCTestCase invokeTest]_block_invoke_2 + 88\n\t45  XCTestCore                          0x0000000103080c1c -[XCTMemoryChecker _assertInvalidObjectsDeallocatedAfterScope:] + 84\n\t46  XCTestCore                          0x00000001030ac220 -[XCTestCase assertInvalidObjectsDeallocatedAfterScope:] + 92\n\t47  XCTestCore                          0x00000001030a2840 __24-[XCTestCase invokeTest]_block_invoke.98 + 172\n\t48  XCTestCore                          0x000000010306c518 -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] + 164\n\t49  XCTestCore                          0x00000001030a23dc -[XCTestCase invokeTest] + 840\n\t50  XCTestCore                          0x00000001030a39dc __26-[XCTestCase performTest:]_block_invoke.155 + 36\n\t51  XCTestCore                          0x000000010306c518 -[XCTestCase(XCTIssueHandling) _caughtUnhandledDeveloperExceptionPermittingControlFlowInterruptions:caughtInterruptionException:whileExecutingBlock:] + 164\n\t52  XCTestCore                          0x00000001030a3530 __26-[XCTestCase performTest:]_block_invoke.141 + 464\n\t53  XCTestCore                          0x000000010308a348 +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] + 180\n\t54  XCTestCore                          0x000000010308a25c +[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 144\n\t55  XCTestCore                          0x00000001030a31bc -[XCTestCase performTest:] + 308\n\t56  XCTestCore                          0x000000010305b3cc -[XCTest runTest] + 48\n\t57  XCTestCore                          0x000000010308cfa4 -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] + 68\n\t58  XCTestCore                          0x000000010308ce84 __27-[XCTestSuite performTest:]_block_invoke + 164\n\t59  XCTestCore                          0x000000010308c934 __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke + 48\n\t60  XCTestCore                          0x000000010308a348 +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] + 180\n\t61  XCTestCore                          0x000000010308a25c +[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 144\n\t62  XCTestCore                          0x000000010308c8d0 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 180\n\t63  XCTestCore                          0x000000010308cb8c -[XCTestSuite performTest:] + 216\n\t64  XCTestCore                          0x000000010305b3cc -[XCTest runTest] + 48\n\t65  XCTestCore                          0x000000010308cfa4 -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] + 68\n\t66  XCTestCore                          0x000000010308ce84 __27-[XCTestSuite performTest:]_block_invoke + 164\n\t67  XCTestCore                          0x000000010308c934 __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke + 48\n\t68  XCTestCore                          0x000000010308a348 +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] + 180\n\t69  XCTestCore                          0x000000010308a25c +[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 144\n\t70  XCTestCore                          0x000000010308c8d0 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 180\n\t71  XCTestCore                          0x000000010308cb8c -[XCTestSuite performTest:] + 216\n\t72  XCTestCore                          0x000000010305b3cc -[XCTest runTest] + 48\n\t73  XCTestCore                          0x000000010308cfa4 -[XCTestSuite runTestBasedOnRepetitionPolicy:testRun:] + 68\n\t74  XCTestCore                          0x000000010308ce84 __27-[XCTestSuite performTest:]_block_invoke + 164\n\t75  XCTestCore                          0x000000010308c934 __59-[XCTestSuite _performProtectedSectionForTest:testSection:]_block_invoke + 48\n\t76  XCTestCore                          0x000000010308a348 +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] + 180\n\t77  XCTestCore                          0x000000010308a25c +[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 144\n\t78  XCTestCore                          0x000000010308c8d0 -[XCTestSuite _performProtectedSectionForTest:testSection:] + 180\n\t79  XCTestCore                          0x000000010308cb8c -[XCTestSuite performTest:] + 216\n\t80  XCTestCore                          0x000000010305b3cc -[XCTest runTest] + 48\n\t81  XCTestCore                          0x000000010305cf14 __89-[XCTTestRunSession executeTestsWithIdentifiers:skippingTestsWithIdentifiers:completion:]_block_invoke + 104\n\t82  XCTestCore                          0x000000010308a348 +[XCTContext _runInChildOfContext:forTestCase:markAsReportingBase:block:] + 180\n\t83  XCTestCore                          0x000000010308a25c +[XCTContext runInContextForTestCase:markAsReportingBase:block:] + 144\n\t84  XCTestCore                          0x000000010305ce08 -[XCTTestRunSession executeTestsWithIdentifiers:skippingTestsWithIdentifiers:completion:] + 296\n\t85  XCTestCore                          0x00000001030c24c0 __72-[XCTExecutionWorker enqueueTestIdentifiersToRun:testIdentifiersToSkip:]_block_invoke_2 + 136\n\t86  XCTestCore                          0x00000001030c2610 -[XCTExecutionWorker runWithError:] + 108\n\t87  XCTestCore                          0x000000010308754c __25-[XCTestDriver _runTests]_block_invoke.266 + 56\n\t88  XCTestCore                          0x0000000103065670 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 288\n\t89  XCTestCore                          0x00000001030871a8 -[XCTestDriver _runTests] + 1092\n\t90  XCTestCore                          0x000000010305b9bc _XCTestMain + 88\n\t91  WebDriverAgentRunner-Runner         0x0000000102a3dd1c -[_XCTRunnerAppDelegate application:didFinishLaunchingWithOptions:] + 0\n\t92  WebDriverAgentRunner-Runner         0x0000000102a3dd00 _XCTRunnerRunTests + 0\n\t93  CoreFoundation                      0x00000001c1be26e0 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 276192\n\t94  CoreFoundation                      0x00000001c1c49210 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 696848\n\t95  CoreFoundation                      0x00000001c1c190e8 4230C122-42E8-383B-BEEC-EE7B61F8BB61 + 499944\n\t96  CoreFoundation                      0x00000001c1c1e3ec CFRunLoopRunSpecific + 612\n\t97  GraphicsServices                    0x00000001fc7db35c GSEventRunModal + 164\n\t98  UIKitCore                           0x00000001c3fab6e8 B3834960-244B-34E4-9EA0-CA4BB44EF0F3 + 3790568\n\t99  UIKitCore                           0x00000001c3fab34c UIApplicationMain + 340\n\t100 WebDriverAgentRunner-Runner         0x0000000102a3ded0 main + 160\n\t101 dyld                                0x00000001e110edec 8A423F3F-B318-315E-99C7-05EE532E9C0D + 89580\n)"
  },
  "sessionId" : "2E9FE934-A41B-469B-AEE9-FAF2D854B5E1"
}%

I haven't reproduced the timeout thing, which actually could happen occasionally even the app is already installed. This implementation maybe can cover such case as well.

@mykola-mokhnach mykola-mokhnach merged commit c4976e3 into master May 16, 2023
@mykola-mokhnach mykola-mokhnach deleted the hack_launch branch May 16, 2023 18:45
github-actions bot pushed a commit that referenced this pull request May 16, 2023
## [5.1.4](v5.1.3...v5.1.4) (2023-05-16)

### Bug Fixes

* Prevent freeze on launch/activate of a missing app ([#706](#706)) ([c4976e3](c4976e3))
@github-actions
Copy link

🎉 This PR is included in version 5.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants