Skip to content

Improve SDK BitmapVideoFilter memory usage#969

Merged
liviu-timar merged 5 commits intodevelopfrom
video-filter-memory-usage-fix
Dec 19, 2023
Merged

Improve SDK BitmapVideoFilter memory usage#969
liviu-timar merged 5 commits intodevelopfrom
video-filter-memory-usage-fix

Conversation

@liviu-timar
Copy link
Contributor

@liviu-timar liviu-timar commented Dec 18, 2023

🎯 Goal

When using BitmapVideoFilter, memory usage increases rapidly and the client app crashes. Memory usage should be stable, GC should be able to keep up.

🛠 Implementation details

Refactored YuvFrame:

  • Used libyuv to copy YUV planes
  • Used buffer rotation insted of bitmap rotation (rotated I420 buffer, which is shorter)
  • Cleaned-up memory
  • Code structure and naming improvements

Released yuvBuffer in FilterVideoProcessor.

🧠 Memory Usage

Demo app profiling with filter enabled in a call on a Pixel 4
Before: Reached ~4 GB in under 5 mins and crashed
memory-usage-high
After: Stays in the 360-590 MB range even after 2h. Stable.
memory-usage-good

🧪 Testing

  • Start a call, enable video filter (background blur) and leave call running.
  • Needs testing on a lower-end device.
  • Needs battery profiling.
  • See test results in comments below.

☑️Contributor Checklist

General

  • I have signed the Stream CLA (required)
  • Assigned a person / code owner group (required)
  • Thread with the PR link started in a respective Slack channel (required internally)
  • PR targets the develop branch

Code & documentation

  • Changelog is updated with client-facing changes

☑️Reviewer Checklist

  • New feature tested and works

🎉 GIF

@liviu-timar
Copy link
Contributor Author

liviu-timar commented Dec 19, 2023

Same call, original blur (without PorterDuff compositing): both phones in call for over 2h.

@liviu-timar liviu-timar marked this pull request as ready for review December 19, 2023 10:40
@liviu-timar liviu-timar requested a review from a team as a code owner December 19, 2023 10:40
@liviu-timar liviu-timar merged commit f8175c7 into develop Dec 19, 2023
@liviu-timar liviu-timar deleted the video-filter-memory-usage-fix branch December 19, 2023 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants