jonathanpenn / ui-screen-shooter

Using UI Automation to automatically generate all screenshots of your iOS app, on different device types, in different locales by running a single command. Hands free.
http://cocoamanifest.net
MIT License
811 stars 61 forks source link

Target failed to run: The operation couldn’t be completed. #69

Open clacladev opened 9 years ago

clacladev commented 9 years ago

Hi Jonathan, thanks for this great script. I really appreciate your work.

I have only one problem. Half of the time when running the script I get the error:

$ ./ui-screen-shooter.sh
[...]
Running automation script "./config-automation.js"
          for "iPad 2"
          in language "en-US"...
Waiting for device to boot...
2014-10-31 15:09:32.009 instruments[44646:1015886] WebKit Threading Violation - initial use of WebKit from a secondary thread.
Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 8.) : Failed to launch process with bundle identifier 'com.xxx.yyy'

After few tries, I've understood that resetting the simulator and re-running the script it works fine.

$ ./ui-screen-shooter.sh
[...]
Running automation script "./config-automation.js"
          for "iPad 2"
          in language "en-US"...
2014-10-31 15:10:31.981 instruments[44764:1017855] WebKit Threading Violation - initial use of WebKit from a secondary thread.
2014-10-31 15:10:34 +0000 Debug: target.captureRectOnScreenWithName("{origin:{x:0.00,y:0.00}, size:{height:1024.00,width:768.00}}", UIScreen, "iOS-iPad___portrait___WelcomeScreen")
2014-10-31 15:10:34 +0000 Screenshot captured.
Instruments Trace Complete (Duration : 3.712188s; Output : /tmp/screen_shooter/traces/trace.trace)

Then problem is that it's unpredictable, so I have to reset the simulator a lot of times. Do you have any idea why this is happening?

I have Xcode 6.1 with an app that run exclusively on iOS 8.1.

Thanks

jonathanpenn commented 9 years ago

The "WebKit Threading Violation" seems weird. Does that happen when you run your app outside of instruments every once in a while?

Unfortunately, Instruments and UI Automation is still not very stable. File a bug with Apple at http://bugreport.apple.com and include these log files and let them know you're using this script. Every bug report helps prioritize things.

clacladev commented 9 years ago

Yes, it happens when I run it from terminal.

I've noted that it happens when is switching from a simulated device to another. If I am running just on one device it's unlikely it happens.

jonathanpenn commented 9 years ago

I meant, does it happen if you run it while just using the app normally (run from Springboard, not just from the terminal)? Regardless, this sounds like an issue within Apple's profiling toolchain. Instruments sometimes just loses connection with the frontmost app, too. The Instruments team is still working out kinks to make it robust. There's nothing that these screen shot scripts can do from the outside. We have to wait for the toolchain.

Please file a bug about this and update the thread with any details if you can. Thanks!

clacladev commented 9 years ago

It happens only when running the script. So when the script switch from a device type to another, probably as you said lose connection and the error is thrown.

Anyway, thanks for your answer and support. I will fill the bug report with Apple.

Have great work and thanks again for the script. Cheers

KrauseFx commented 9 years ago

I'm having the exact same problem. Only way to 'solve' it, is to wait for a few seconds and try to run it again. I'm currently working on a fix for that issue. I think it has nothing to do with Webkit itself, that's just a warning from a different problem.

KrauseFx commented 9 years ago

@ccarnino Sorry to just advertise another open source project, but Snapshot solves exactly this problem.

Take a look at the gif: Instruments failed again... trying again. That's when Snapshot detects this error and tries again.

KrauseFx commented 9 years ago

In case you want to implement this fix in ui-screen-shootercheck out runner.rb:87

It's enough to re-run this one test after a few seconds delay.

clacladev commented 9 years ago

Thanks Felix for the advice. I will try this for sure to see if the overall process works better.

Cheers

--  Claudio Carnino Co-founder of Fanchimp.com About me on TuguLab.org

"We want the world and we want it now" The Doors

On 15 November 2014 at 12:27:29, Felix Krause (notifications@github.com) wrote:

In case you want to implement this fix in ui-screen-shootercheck out runner.rb:87

It's enough to re-run this one test after a few seconds delay.

— Reply to this email directly or view it on GitHub.

damcify commented 9 years ago

I added this crude code myself. Seems to work... not fully tested yet though.

 until "$DIR"/unix_instruments.sh  
 -w "$simulator" \  
 -D "$trace_results_dir/trace" \  
 -t "$tracetemplate" \  
 $bundle_dir \  
-e UIARESULTSPATH "$trace_results_dir" \  
-e UIASCRIPT "$automation_script" \  
-AppleLanguages "($language)" \  
-AppleLocale "$language" \  
$* ; do  
  echo Instruments failed to start up... retrying in 2 seconds  
  sleep 2  
done `    

Thanks to this post: http://serverfault.com/questions/80862/bash-script-repeat-command-if-it-returns-an-error