mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-11 18:17:46 +00:00
* WIP: Haskell impl of resizeImageToStrSize * WIP: add FFI export wrapper * WIP: switch ios resizeImageToStrSizeSync to backend * WIP: fix resizeImageToStrSizeSync * WIP: add JNI wrappers * Add non-base64 resize and cWriteImage * WIP: add chat_write_image * fix resizeToStr * fixes * fix syntax, raise jpeg quality back * add chatWriteImage * Fix cfArgs in tests * Use jpeg-turbo encoder * add nix pins * bump jpeg-turbo * add CI deps * add encoding funs to android lib * bump jpeg-turbo for 20.04 fix * jpeg-turbo fix for 8.10 * android fixes * Bump jpeg-turbo * set static flag for jpeg-turbo * Fix nix for aarch64/android * Fix android C api * Fix resize in android * Bump hs-libjpeg-turbo * target correct override * override android lib from android pkgs * add macos build tweaks * bump hs-jpeg-turbo for 8.10 fixes * more build fixes * make ios compile * Always use pkgconfig for libjpeg-turbo * WIP: debug libjpeg in ubuntu pkg-config CI * Add pkg-config to dockerfiles * Add libturbojpeg to dockerfiles * Use -dev version of libturbojpeg in dockerfiles * Install pkg-config in windows CI * Disable flag for custom libturbojpeg linking options Workarounds relocation error on x86_64-linux with gcc: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/libturbojpeg.a(turbojpeg.c.o): relocation R_X86_64_TPOFF32 against `errStr' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: failed to set dynamic section sizes: bad value * WIP: debug libjpeg in windows pkg-config CI * WIP: debug libjpeg package in windows CI * core: image resize module and buffer FFI * ci: link libjpeg-turbo statically on all platforms * ui: resize images in the core * core: rename image resize functions to chat_resize_image and chat_resize_image_uri * ci: restore whitespace in build.yml * ci: build libjpeg-turbo 3.1.4.1 from a submodule * core: hs-jpeg-turbo from github.com/simplex-chat * nodejs: resize images * python: resize images * core: hs-jpeg-turbo from gitlab.com, the GitHub import lacks LFS objects * core: generate /img previews * ci: link libjpeg-turbo on Windows without pkg-config * ci: build libjpeg-turbo on Windows with the GHC toolchain * docs: plan for image resizing in the core * docs: update image resizing plan * ios: prevent crash when wallpaper image cannot be resized * android, desktop: raise an error when an image cannot be resized * docs: update spec references for image resizing * docker: build the CLI image from a clone without submodules * docs: apply review fixes to image resizing plan * docker: build the CLI from a git worktree with the submodule present * docs: apply second review to image resizing plan * docs: point image resizing plan at the rewritten commit * core: choose image format by transparency in chat_resize_image * nodejs: resize images to the app sizes * python: resize images to the app sizes * nodejs, python: describe the core modules as used for image resizing * docs: add license notices of the image libraries * ci: describe the avatar method without attributing it to the apps * ci, ios, nix: remove the libjpeg-turbo build outside cabal * python: name resize_image in the core module text * nodejs, python: describe resizing to the app image sizes * core: refuse images larger than the supported size * core: resize to JPEG images with a side above 65500 pixels * docs: record image resizing decisions for the bundled libjpeg-turbo * core, docs: build libjpeg-turbo and stb from the fork submodules * docs: record the fork pins in the image resizing plan * core: resize images to at most 4320 pixels per side, refuse above 16384 * docs: record the image side limits in the image resizing plan * core: pin the rebased hs-jpeg-turbo fork * core: pin the hs-jpeg-turbo fork without package.yaml * docs: plan scaled JPEG decoding and EXIF orientation of images * docs: copy the JuicyPixels-stbir licence of the pinned fork * core: pin the hs-jpeg-turbo fork with scaled JPEG decoding * core: decode JPEG at the display size, up to 65500 pixels per side * core: rotate JPEG images by their EXIF orientation * docs: refer the image plan to the JPEG decoding code * docs: record the approved image processing decisions * core: limit JPEG decoding memory to 1024 MB outside iOS and Android * docs: name JPEG decoding in the libjpeg-turbo notice * docs: plan image resizing from files and the decisions of 26 Oct * core: scale images in one Catmull-Rom pass with sharpening * docs: plan image sizes at a fixed quality * core: resize images at a fixed quality to fill the size limit * core: resize images from a file path or a file descriptor * ios, android, desktop: resize picked images from their files * core: encode resized images with mozjpeg * tests: check descriptor closing by the file it refers to * core: raise JPEG quality only for a full-size image below 97% of the limit * ci: name the mozjpeg submodule in the Windows cleanup comments * docs: refer the image plan to the current code * docs: refer the image plan to the code merged with master * core: export every image resizing function from each library * core: close the file descriptor when its handle cannot be created * docs: count the C sources of mozjpeg with the arithmetic decoder * core: use the reviewed hs-jpeg-turbo and JuicyPixels-stbir forks * ci: build the armv7a Android core library on request * core: round image heights half up in the size search * ios: describe the file image resizing functions in SimpleX.h * ci: pick, preview and send images in the Claude app tests * core: decode PNG images with libspng and refuse other formats * core: encode PNG with libspng, keeping the smaller filter choice * ci: pick, preview and send images in the scripted app smoke tests * flake: build the PNG decoder package in nix builds * ios: remove the copy of a picked image after sending it * core: refuse image files larger than the decode memory limit * core: scale a JPEG image to its largest size once per resize * core: bisect JPEG quality without a step function * core: reduce the memory used to sharpen and to decode PNG images * android, desktop: pass the image format to the core as an integer * android, desktop: fuse the preview conditions of picked media * android, desktop, ci: check that the core resized the smoke test images * python: remove the docstrings of the explicit image resizing functions * docs: add the second review fixes to the image plan * ci: tap the iOS attachment button by its accessibility label * core: keep the colour profiles of resized images * docs: add the colour profiles to the image plan * ci: wait up to 30 s for the new group screens in the iOS smoke test * ci: pick the Android smoke test images from their own photo folders * ci: tap the iOS photo picker by position, as its tree is not shown * ci: pick the test card and the logo by their iOS picker positions * core: update JuicyPixels-stbir with the stb_image_resize licence terms * core: write a fixed Display P3 profile for Display P3 images only * core: do not keep the input image in memory for its colour profile * core: read the JPEG segments once for the orientation and the profile * core: read an image file into one buffer of its size * docs: add the third review fixes to the image plan * core: resize images with Display P3 or no profile, not profile bytes * ci: check the pixel sizes of the images sent in the iOS smoke test * core: update hs-jpeg-turbo with PNG chunk limits and encoder fixes * docs: list Compact ICC Profiles, libspng and miniz in the dependencies * android, desktop: reword the picked media preview comment * docs: refer the image plan to the code merged with master * ci: render the iOS snapshots before the images case * ci: dismiss the snapshot tests' camera alert before the iOS images case * core: update hs-jpeg-turbo with tests and the JuicyPixels-spng synopsis * core: pin hs-jpeg-turbo and JuicyPixels-stbir in simplex-chat repositories * update ios core library * core, ui: accept only JPEG and PNG image data * core: update JuicyPixels-stbir * docs: plan for the iOS copy of picked images --------- Co-authored-by: IC Rainbow <aenor.realm@gmail.com> Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com> Co-authored-by: Alexandre Esteves <alexfmpe@proton.me>
225 lines
7.5 KiB
Bash
Executable File
225 lines
7.5 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
# Installs the app in a new iPhone simulator and runs the scripted UI cases with the ui helper: onboarding to the
|
||
# chat list with the one-hand UI (the default), then the chat list again with the top bar. It leaves the app in the one-hand UI.
|
||
# For an app in the derived data of a build, it then renders the previews of the SimpleX Snapshots tests to the snapshots
|
||
# folder of the output dir (snapshots.sh).
|
||
# With "images" it then turns off the encryption of local files, creates a group and sends tests/fixtures/test.jpg and
|
||
# logo-large-rgba.png picked in the photo library, and checks the pixel sizes of the sent files.
|
||
# Usage: scripts/ci/ios-sim/smoke-test.sh <path to SimpleX.app> <output dir> [images]
|
||
# Each step saves a screenshot and an accessibility tree to the output dir and prints the tree to the log.
|
||
# Later steps of the job get SIM_UDID and UI_OUT, with the simulator still running.
|
||
|
||
set -euo pipefail
|
||
|
||
app=$1
|
||
export UI_OUT=$2
|
||
cases=${3:-}
|
||
bundle_id=chat.simplex.app
|
||
ui=$(dirname "$0")/ui
|
||
fixtures=$(cd "$(dirname "$0")/../../../tests/fixtures" && pwd)
|
||
test_card_x=66
|
||
logo_x=200
|
||
photo_y=412
|
||
picker_done_x=363
|
||
picker_done_y=144
|
||
mkdir -p "$UI_OUT"
|
||
|
||
axe --version
|
||
runtime=com.apple.CoreSimulator.SimRuntime.iOS-$(xcrun --sdk iphonesimulator --show-sdk-version | tr . -)
|
||
SIM_UDID=$(xcrun simctl create ci-iphone com.apple.CoreSimulator.SimDeviceType.iPhone-17 "$runtime")
|
||
export SIM_UDID
|
||
echo "simulator $SIM_UDID, runtime $runtime"
|
||
if [ -n "${GITHUB_ENV:-}" ]; then
|
||
echo "SIM_UDID=$SIM_UDID" >> "$GITHUB_ENV"
|
||
echo "UI_OUT=$UI_OUT" >> "$GITHUB_ENV"
|
||
fi
|
||
xcrun simctl boot "$SIM_UDID"
|
||
xcrun simctl bootstatus "$SIM_UDID" -b
|
||
open -a Simulator --args -CurrentDeviceUDID "$SIM_UDID"
|
||
|
||
xcrun simctl spawn "$SIM_UDID" log stream --level debug --style compact --predicate 'process == "SimpleX"' > "$UI_OUT/app.log" 2>&1 &
|
||
log_pid=$!
|
||
|
||
finish() {
|
||
local status=$?
|
||
"$ui" shot final || true
|
||
kill "$log_pid" || true
|
||
echo "::group::core start in the app log"
|
||
grep -E 'chatMigrateInit|startChat' "$UI_OUT/app.log" || true
|
||
echo "::endgroup::"
|
||
echo "::group::app log, last 300 lines"
|
||
tail -n 300 "$UI_OUT/app.log"
|
||
echo "::endgroup::"
|
||
find ~/Library/Logs/DiagnosticReports -name 'SimpleX*' -newer "$app" 2>/dev/null | while read -r report; do
|
||
echo "::group::crash report $report"
|
||
head -n 200 "$report"
|
||
echo "::endgroup::"
|
||
done || true
|
||
exit "$status"
|
||
}
|
||
trap finish EXIT
|
||
|
||
expect_in_tree() {
|
||
local tree
|
||
tree=$("$ui" tree)
|
||
if ! grep -q "$@" <<< "$tree"; then
|
||
echo "error: ${*: -1} is not in the accessibility tree"
|
||
exit 1
|
||
fi
|
||
}
|
||
|
||
# iOS asks once whether the app may send notifications. The tree sometimes shows the app under this alert rather than
|
||
# the alert (run 38895987656), so its Allow button is also looked for at its place.
|
||
allow_notifications() {
|
||
local deadline=$((SECONDS + 30)) element
|
||
while [ "$SECONDS" -lt "$deadline" ]; do
|
||
if "$ui" tap Allow 1; then
|
||
return
|
||
fi
|
||
element=$("$ui" point 275 518 || true)
|
||
if grep -qF '"Allow"' <<< "$element"; then
|
||
"$ui" tap-xy 275 518
|
||
return
|
||
fi
|
||
sleep 2
|
||
done
|
||
echo "no notifications alert to allow"
|
||
}
|
||
|
||
# a profile without conversations sees the onboarding pages in place of the list
|
||
expect_chat_list() {
|
||
expect_in_tree -F '"Talk to someone"'
|
||
expect_in_tree -F 'Button "Let someone connect to you"'
|
||
expect_in_tree -F 'Button "Connect via link or QR code"'
|
||
expect_in_tree -F 'Button "Compose"'
|
||
echo "in the $1 layout the chat list shows the onboarding pages and the toolbar"
|
||
}
|
||
|
||
tap_element() {
|
||
local line x y w h
|
||
line=$("$ui" tree | grep -iE "^$1 \"$2\"" | tail -n 1)
|
||
[ -n "$line" ] || return 1
|
||
read -r x y w h < <(sed -E 's/.* at (-?[0-9]+),(-?[0-9]+) size ([0-9]+)x([0-9]+).*/\1 \2 \3 \4/' <<< "$line")
|
||
"$ui" tap-xy $((x + w / 2)) $((y + h / 2))
|
||
}
|
||
|
||
sent_files() {
|
||
find "$(xcrun simctl get_app_container "$SIM_UDID" "$bundle_id" group.chat.simplex.app)" "$(xcrun simctl get_app_container "$SIM_UDID" "$bundle_id" data)" -name "IMG_*.$1" 2> /dev/null | wc -l
|
||
}
|
||
|
||
sent_file() {
|
||
local deadline=$((SECONDS + 30))
|
||
until [ "$(sent_files "$1")" -gt "$2" ]; do
|
||
[ "$SECONDS" -lt "$deadline" ] || return 1
|
||
sleep 2
|
||
done
|
||
}
|
||
|
||
sent_size() {
|
||
local file
|
||
file=$(find "$(xcrun simctl get_app_container "$SIM_UDID" "$bundle_id" group.chat.simplex.app)" "$(xcrun simctl get_app_container "$SIM_UDID" "$bundle_id" data)" -name "IMG_*.$1" -exec ls -t {} + 2> /dev/null | sed -n 1p)
|
||
sips -g pixelWidth -g pixelHeight "$file" | awk '/pixelWidth/ {w = $2} /pixelHeight/ {h = $2} END {print w "x" h}'
|
||
}
|
||
|
||
disable_file_encryption() {
|
||
xcrun simctl terminate "$SIM_UDID" "$bundle_id" 2> /dev/null || true
|
||
xcrun simctl spawn "$SIM_UDID" defaults write "$(xcrun simctl get_app_container "$SIM_UDID" "$bundle_id" group.chat.simplex.app)/Library/Preferences/group.chat.simplex.app" privacyEncryptLocalFiles -bool false
|
||
"$ui" relaunch
|
||
}
|
||
|
||
fail() {
|
||
echo "error: $*"
|
||
exit 1
|
||
}
|
||
|
||
create_group() {
|
||
"$ui" tap Compose
|
||
"$ui" tap "Create group" 30
|
||
"$ui" tap-value "Enter group name…" 30
|
||
"$ui" type "image notes"
|
||
"$ui" shot new-group
|
||
tap_element Button "Create group" || fail "no \"Create group\" button"
|
||
"$ui" tap Skip 10 || true
|
||
"$ui" shot group-created
|
||
}
|
||
|
||
app_resized_images() {
|
||
grep -cE "resizeImageTo(Str|Data)Size final" "$UI_OUT/app.log" || true
|
||
}
|
||
|
||
send_image() {
|
||
local ext=$1 photo_x=$2 size=$3 sent resized
|
||
sent=$(sent_files "$ext")
|
||
resized=$(app_resized_images)
|
||
tap_element Button "Attachements" || fail "no attachment button"
|
||
"$ui" tap "Choose from library"
|
||
sleep 3
|
||
"$ui" shot "picker-$ext"
|
||
"$ui" tap-xy "$photo_x" "$photo_y"
|
||
"$ui" shot "picker-selected-$ext"
|
||
"$ui" tap-xy "$picker_done_x" "$picker_done_y"
|
||
sleep 3
|
||
"$ui" shot "preview-$ext"
|
||
"$ui" find multiply || fail "$ext: no image preview in the compose area"
|
||
tap_element Button "[^\"]*arrow[^\"]*" || fail "no send button"
|
||
sent_file "$ext" "$sent" || fail "$ext: no .$ext file sent"
|
||
"$ui" shot "sent-$ext"
|
||
[ "$(sent_size "$ext")" = "$size" ] || fail "$ext: the sent image is $(sent_size "$ext"), not $size"
|
||
[ "$(app_resized_images)" -eq "$resized" ] || fail "$ext: the app resized the image in place of the core"
|
||
echo "$ext: the picked image was previewed and sent as a $size .$ext file"
|
||
}
|
||
|
||
xcrun simctl install "$SIM_UDID" "$app"
|
||
xcrun simctl launch "$SIM_UDID" "$bundle_id"
|
||
|
||
# onboarding to the chat list
|
||
"$ui" wait "Get started" 180
|
||
"$ui" shot first-screen
|
||
"$ui" tap "Get started"
|
||
|
||
"$ui" wait "Create profile" 30
|
||
"$ui" tap-value "Enter profile name..."
|
||
"$ui" type citester
|
||
"$ui" shot profile-name
|
||
"$ui" tap "Create profile"
|
||
|
||
"$ui" wait "Continue" 60
|
||
"$ui" shot your-network
|
||
"$ui" tap "Continue"
|
||
|
||
"$ui" wait "Accept" 30
|
||
"$ui" shot network-commitments
|
||
"$ui" tap "Accept"
|
||
|
||
sleep 5
|
||
"$ui" shot after-onboarding
|
||
allow_notifications
|
||
"$ui" shot notifications-allowed
|
||
|
||
"$ui" wait "Talk to someone" 60
|
||
"$ui" shot chat-list
|
||
expect_chat_list reachable
|
||
|
||
# ui layout checks that the toolbar moved
|
||
"$ui" layout top
|
||
"$ui" shot chat-list-top
|
||
expect_chat_list top
|
||
"$ui" layout reachable
|
||
echo "smoke test passed: onboarding reaches the chat list, which shows its onboarding pages and toolbar with the one-hand UI and with the top bar"
|
||
|
||
products=$(dirname "$app")
|
||
if [[ "$products" == */Build/Products/Debug-iphonesimulator ]]; then
|
||
"$(dirname "$0")/snapshots.sh" "${products%/Build/Products/Debug-iphonesimulator}" "$UI_OUT/snapshots"
|
||
fi
|
||
|
||
if [ "$cases" = images ]; then
|
||
"$ui" tap "Don’t Allow" 10 || true
|
||
disable_file_encryption
|
||
xcrun simctl addmedia "$SIM_UDID" "$fixtures/test.jpg" "$fixtures/logo-large-rgba.png"
|
||
create_group
|
||
send_image jpg "$test_card_x" 1280x720
|
||
send_image png "$logo_x" 1630x466
|
||
echo "smoke test passed: images"
|
||
fi
|