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
[snapshot] Ability to record video #10121
Conversation
…Helper.swift" -> "snapshot.rb" communication to remove a dependency. Feedback addressed @KrauseFx
rubocop
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
I need to do some changes to apply recent changes on Snapshot |
…with Xcode 9 (fastlane#9570)' change (Only for xCode 8 for now)
done, all is working now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super cool! Requested one change to add method doc on execute
for new parameter.
Also, is there anyway to add tests for this?
@@ -30,7 +30,7 @@ def which(cmd) | |||
# @param prefix [Array] An array containing a prefix + block which might get applied to the output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get the pidCreated
added to this comment/doc here? ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Hey @laullon, that's so awesome, thanks for your contribution, I love the idea to use snapshot to create videos. Could you tell us a little more about why we need a HTTP server to communicate? I thought it should be possible to do that without a web server. |
I need this PR to be approved so much... Really appreciate the work @laullon ! |
I added the "HTTP Server" because I need a way to communicate the XCTests running on the simulator and the Snapshot process, so it knows when start and stop the recording. I did it that way because:
This doesn't represent a security problem because this server only support 2 get URLs, any other URL or HTTP command is ignored, any HTTP header is also ignored, and it listen on a different port every time. |
Yeah, I'm not too worried about the security in this case, but about the complexity that this will add to the code base |
yeah, "HTTP Server" sounds complex, but is really very simple... Anyway, if you have a better way in mind let me know, I'll try it. |
This is a great addition to snapshot - especially since Apple is pushing towards the usage of videos in the AppStore. What is the current position on this PR? Does is need some more testing or is the http server a problem? The http server might be handy for further additions / actions to control the simulator. |
Yeah, I thought it's possible using
|
I use "xcrun simctl io" to record the video, but I don't use the "booted" option because in Xcode 9 you can have multiple simulator running, so it had to called with a divide ID. |
Yeah, but that should still work, right? First, launch up a simulator, get its UDID, and then use that to record the video. For video recording in snapshot (or a new action/tool?), I feel like it would totally be okay to require Xcode 9 to use the feature |
That's what I do... and It works on Xcode 8 and 9 |
sendCommand(commnad: "stopRecording") | ||
} | ||
|
||
func sendCommand(commnad: String,args: String = "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo in the attribute name: commnad
should be command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved
# @param error [Block] A block that's called if an error occurs | ||
# @param prefix [Array] An array containing a prefix + block which might get applied to the output | ||
# @param loading [String] A loading string that is shown before the first output | ||
# @return [String] All the output as string | ||
def execute(command: nil, print_all: false, print_command: true, error: nil, prefix: nil, loading: nil) | ||
def execute(command: nil, print_all: false, print_command: true, pidCreated: nil, error: nil, prefix: nil, loading: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other attributes of this function all use snake_case instead of camelCase. This should be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solved
I agree with @KrauseFx on this. There should be a simpler way to pass the command from Xcode to fastlane other than using a http server. Maybe it just has to try it from another direction: don't start to record from inside of the UITest, but start the relevant parts of the UITest from outside of Xcode (before/after starting to record). I could imagine something like scan(only_testing: "TestBundleA/TestSuiteVideo") directly followed this part of your code Thread.new do
FastlaneCore::CommandExecutor.execute(command: "xcrun simctl io booted recordVideo #{language_folder}/#{name}.mp4",
print_all: true,
print_command: true,
loading: "Recording video...",
pidCreated: proc do |pid|
@recording_pid = pid
end,
error: proc do |output, return_code|
ErrorHandler.handle_test_error(output, return_code)
UI.error "Caught error... #{return_code}"
UI.error "Caught output... #{output}"
end)
end |
* master: (96 commits) [snapshot] Fix unused result warning in helper (fastlane#10662) Typo Fix (fastlane#10661) Version bump to 2.62.1 (fastlane#10670) Support manual signingStyle (fastlane#10508) Dont count lane switches in metrics (fastlane#10659) Add missing html tag (fastlane#10657) Deprecates add_id_info_limits_tracking in favor of add_id_info_uses_idfa (fastlane#10653) [fastlane core] fix unit tests when Xcode 9.0 not installed (fastlane#10655) Add automatic commiting of mkdocs.yml for docs generation (fastlane#10578) [Client] Handle Faraday::ParsingError as part of Client#with_retry logic (fastlane#10646) Revert "[BuildWatcher] Handle parse error while waiting for build processing (fastlane#10621)" (fastlane#10647) [BuildWatcher] Handle parse error while waiting for build processing (fastlane#10621) Remove 'zip' example from update_info_plist (fastlane#10494) Make plugin details optional (fastlane#10628) fix leaking sw_vers (fastlane#10630) Update snapshot instructions (fastlane#10626) Update update instructions of snapshot (fastlane#10627) Don't add unneeded new-line when asking for user input (fastlane#10629) Forward match keychain password into cert (fastlane#10619) SW_VERS should be lowercase (fastlane#10625) ... # Conflicts: # README.md # cert/README.md # snapshot/README.md # snapshot/lib/assets/SnapshotHelper.swift
Hey folks! I am just going through some older PRs and checking out the status of them. I wanted to bump this in case there was any more discussion to be had and see if we still thought this should get merged in. @laullon did you have a chance to consider the feedback of the http server? |
Thanks everyone, I'm gonna go ahead and close the PR for now. I think we should be able to implement video recording feature in snapshot without the need of setting up a local HTTP server Thanks for everyone's contribution on this, and sorry for having to close this PR at this time |
Any ideas how to get rid of the 1 second of black screen at the start of the video :( Edit: this could be several seconds. Also it delayed my first view controller in the video. I’m pretty sure the snapshot erase simulator was the cause. @laullon any chance you can merge in recent changes from master? I tried on another branch and couldn’t get it to work, I reckon your more familiar with your changes. One suggestion I do have is that the success of the snapshot still requires a screenshot, also putting the video in the results page would be good. However this all works for me, good job. For anyone else reading, I was confused over the http listener stuff but this is all contained within the swift / fastlane, you don’t need to do anything in your app to use this. |
I'm not working on this right now... don't have time to it... |
Yeah thats me :) |
ohhh!!! right ;) |
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validMotivation and Context
This change add Snapshot to the ability to record videos of iOS applications, using the same method used to take screenshots.
There is a bug open for this: #8759
This was tested using:
Description
I have created a light/simple HTTP server that is used by
SnapshotHelper.swift
to send thestartRecording
andstopRecording
commands tosnapshot.rb
that will execute\kill thexcrun simctl io booted recordVideo