skia2/experimental/tools/web_to_skp
Bryce Thomas 88ecb7f580 Add sleep option to web_to_(skp|mskp) shell scripts.
On slower machines, invoking |chrome.gpuBenchmarking.printToSkPicture|
too early after the headless browser is launched leads to no .skp
files being captured.  Adding a sleep after the launch of the headless
browser rectifies the issue.

Bug: NONE
Change-Id: I39178f8336b794a6f293bd337aca0b6f85a07360
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297805
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-06-19 19:06:29 +00:00

38 lines
1.1 KiB
Bash
Executable File

#! /bin/sh
# Copyright 2018 Google Inc.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if [ "$(uname)" = Linux ]; then
EXAMPLE='/opt/google/chrome/chrome'
elif [ "$(uname)" = Darwin ]; then
EXAMPLE='"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
else
EXAMPLE='"/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"'
fi
if [ $# -lt 3 ] || ! [ -x "$1" ]; then
cat >&2 << EOF
usage:
$0 CHROMIUM_BINARY SOURCE_URL DESTINATION_DIRECTORY
$0 CHROMIUM_BINARY SOURCE_URL DESTINATION_DIRECTORY OPTIONAL_WAIT_TIME # 5 second sleep before capture
e.g:
$0 $EXAMPLE https://www.google.com/ /tmp/
$0 $EXAMPLE https://www.google.com/ /tmp/ 5
EOF
exit 1
fi
EXE="$1"
URL="$2"
DST="$3"
SLP=${4:-0} # sleep in seconds before capture. 4th param iff provided, else 0.
CRASH=~/tmp/headless_crash_dumps
mkdir -p "$CRASH" "$DST"
(sleep $SLP; printf 'chrome.gpuBenchmarking.printToSkPicture("%s");\nquit\n' "$DST") | \
"$EXE" --headless --disable-gpu --repl -crash-dumps-dir="$CRASH" \
--no-sandbox --enable-gpu-benchmarking "$URL"