This adds
- `BackgroundBlurGPUProcessor` a file that handles the openGL logic, and acts as an abstraction over the inner workings of the image processing. OpenGL's logic is ... very unclear. I tried my best to document as much as possible, including any linear algebra that I had to perform.
- `background_blur_vertex.glsl` the required vertex shader, needed to identify the position of each pixel on the screen, before the geometry, rasterization, and fragment shader steps of the openGL pipeline.
- `gaussian_blur_frag_shader.glsl` the Gaussian Blur implementation, this is what actually performs the logic on the image pixels. The code is also somewhat unclear if you're not familiar with shaders or gaussian blur. It helps to read the technical article I commented from Intel.
- `seg_mask_frag_shader.glsl` the masking operation implementation, very simple, just checking if the pixel should be blurred or retain it's original unblurred value
- `testing_frag_shader` a simple fragment shader used for quick testing
- `libyuv_android` a light weight helper lib for converting between image formats without the overhead of OpenCV
Significant changes
- `BackgroundBlurFrameProcessor` now holds it's own dedicated Thread and Handler for running OpenGL's GPU operations. It also takes in a reference to the `surfaceTextureHelper` from `CallActivity` to send the `VideoFrame` objects to the WebRTC `VideoSink` on the appropriate capture thread. Failing to do both of these causes a crash.
Signed-off-by: rapterjet2004 <[email protected]>
So unfortunately the big size of the talk app is caused by the background blur feature.
The model itself is not a problem (selfie_segmenter.tflite is "only" 249,5 KB).
But the dependencies
implementation 'com.google.mediapipe:tasks-vision:0.10.26'
implementation 'org.opencv:opencv:4.12.0'
will result in the shared object libraries
libopencv_java4.so
libmediapipe_tasks_vision_jni.so
and i guess also
libc++_shared.so
Together they are about 145 MB which explains most of the increased size.
Of course there are options to reduce apk sizes but this wont be able to compensate this high number.
One option would be to offer split apks or switch to AAB, but this would make the shipping complicated esp if we want to offer the app as direct downloads.
Build process will be more complicated, People will be confused which apk they have to use or how to get the downloaded aab as app on their phone, branding will be more complex, testing will be harder and so on...
So far i did not find any post from google for plans to require also existing apps to migrate to AAB, so apk should still be future proof.
One other option to reduce the size is to drop support for x86.
I tried this while keeping the background blur feature and ended up with
128 MB.
But as Google limits the upload size for apps to 100MB this may not help unless we further optimize with proguard etc.
We are already at 107 MB for the last releases that don't have the background blurring feature, so even without the feature we may have to act anytime soon, it was just luck google did not complain (maybe other calculation of MB's..).
Dropping support for x86 may be problematic for older ChomeOS systems but nevertheless they should still be able to use the app with arm translation: https://developer.android.com/topic/arc/device-support?utm_source=chatgpt.com#arm-translation.
From the numbers, dropping support for x86 should be fine (screenshot will follow. i don't think the "Unreported ABI" should contain many x86 devices?)
So while mentioning the dropping support for x86:
If dropping is an option AND we would remove the blurring feature as well, we should end up at about ~60MB apk size (did not test yet) which should be future proof for us.
There is also the option to use
packagingOptions {
jniLibs {
useLegacyPackaging true
}
https://developer.android.com/guide/practices/page-sizes?utm_source=chatgpt.com#agp_version_85_or_lower
I tried this and ended up with 140MB while keeping the blurring feature. So still too big and using the useLegacyPackaging is not recommended nowadays. It will most likely cause problems for the future, so it's not a good idea.
So to be honest i think removing the background blurring feature will unfortunately be the best option.
Signed-off-by: Marcel Hibbe <[email protected]>