BodyPix - drawBokehEffect stretched background on Safari Browsers (MacOS - iOS)
System information
- Wrote custom code and tried stock examples.
- macOS Big Sur 11.1
- Safari iOS browser
- TensorFlow.js installed from (npm and script link): 1.2 for script link & tfjs-core 3.1.0 npm version
- Browser version: Safari Version 14.0.2 (16610.3.7.1.9)
- Tensorflow.js Converter Version: 3.1.0
Describe the current behavior
On Safari browsers when blurring the background of video tracks coming from a navigator.mediaDevices.getUserMedia stream, the blurred background seems stretched.
Assuming this is a Safari only issue, I think an aspect ratio fix on the cpuBlur function should do it. 😉
Describe the expected behavior drawBokehEffect expected behavior
Standalone code to reproduce the issue Opening the codepen below in Safari should immediately reproduce the bug. https://codepen.io/guillaume250/pen/ZEBVPaG
- Cheers
Hi @guillaume250. Thanks for the codepen reproduction! drawBokehEffect bases its output dimensions on the video element's width and height properties (although perhaps it shouldn't). If you set the video element's width and height to match the camera's aspect ratio, the output should have the correct aspect ratio. See my fork of your codepen as an example.
Feel free to re-open if this doesn't solve the issue.
Hi @mattsoulanille, thanks for the quick response, and the fork. I just opened your fork in a safari browser and still see the same issue.

I initially thought your report was about the incorrect aspect ratio of the output image, but I've been able to reproduce the issue you're seeing on Safari. I'll take a look. Thanks!
Any updates on this issue? @mattsoulanille how have you overcome issue?
can you please check with latest body segmentation model and let us know if this is resolved ?
Just checked with [email protected] CDN version. Issue still there
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.
@guillaume250 we will not be updating body-pix , there is a new body segmentation model here https://blog.tensorflow.org/2022/01/body-segmentation.html , did you get chance to check this out? Thank you
Closing as stale. Please @mention us if this needs more attention.