-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: change screenshot image format from Jpeg to WebP #273
base: main
Are you sure you want to change the base?
Conversation
Removed some of the vendored code that is not called when encoding an image to webp (e.g decoding parts, dealing with animated webp etc). Test coverage is better now but there are still some files with close to 0% coverage which suggests there's still some code that can be removed. However, I don't feel comfortable stripping this further tbh. I'll try to check bundle size delta next and if we are satisfied I'll leave this as is for now |
# Conflicts: # CHANGELOG.md # PostHog.xcodeproj/project.pbxproj
@marandaneto can you try |
works for me but I see this error in CI: ❌ /Users/runner/work/posthog-ios/posthog-ios/vendor/libwebp/include/types.h:20:10: include of non-modular header inside framework module 'PostHog.types': '/Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/inttypes.h' [-Werror,-Wnon-modular-include-in-framework-module] #include <inttypes.h> Check the CI |
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.
once we make CI happy, we can merge this
Yeah I think you may be right! I'd downloading some older runtimes and I'll check. We should be safe since I see here that libwebp has iOS >= 6 https://github.com/webmproject/libwebp/blob/e4f7a9f0c7c9fbfae1568bc7fa5c94b989b50872/iosbuild.sh#L17C10-L17C25 |
💡 Motivation and Context
Motivation is to reduce the size of our replay snapshots by switching to a more compressed image format.
From empirical testing on our sample apps, WebP is around ~40% more compressed than JPEG.
Why WebP?
Alternative formats
WebP on iOS:
Unfortunately, there's no native support for encoding WebP images in iOS. (iOS added support for decoding in iOS 14).
To add support we vendored in libwebp which is the standard lib for WebP encoding.
We had to change our package definitions both for Cocopods and SPM, which differ a bit because:
import libwebp
use_frameworks!
is standard), or at least I couldn't get it to work.Checklist:
swift package describe
pod spec lint PostHog.podspec --allow-warnings
💚 How did you test it?
@marandaneto I'll need your help testing this out, especially verifying that we didn't break package builds for people.
📝 Checklist