Skip to content

Fix Android OOM in file-based signing - #5

Merged
redaranj merged 2 commits into
guardianproject:mainfrom
divinevideo:fix/android-oom-filestream
Mar 7, 2026
Merged

redaranj merged 2 commits into
guardianproject:mainfrom
divinevideo:fix/android-oom-filestream

Conversation

@dcadenas

@dcadenas dcadenas commented Mar 6, 2026

Copy link
Copy Markdown

Summary

Replace readBytes() + ByteArrayStream with FileStream in 5 file-based code paths. FileStream streams from disk via RandomAccessFile instead of loading entire files into JVM heap.

Fixes #4

Problem

30 OOM crashes in production. After video capture and editing, the JVM heap is nearly full. readBytes() tries to load the video file into memory and fails — even for small files (7-16MB).

Test

Added a regression test that simulates production conditions: fills the JVM heap via a test helper method channel, then signs a 15MB MP4. Crashes without the fix, passes with it.

Replace readBytes() + ByteArrayStream with FileStream in 5 file-based
code paths. FileStream streams from disk via RandomAccessFile instead
of loading entire files into JVM heap.

Add OOM regression test that simulates production conditions by filling
JVM heap via test helper, then signing a 15MB MP4.

Fixes guardianproject#4
@n8fr8 n8fr8 self-assigned this Mar 6, 2026
@redaranj
redaranj merged commit 6c546aa into guardianproject:main Mar 7, 2026
6 of 8 checks passed
@n8fr8

n8fr8 commented Mar 7, 2026

Copy link
Copy Markdown
Member

Submitting this fix into Divine now

@n8fr8

n8fr8 commented Mar 7, 2026

Copy link
Copy Markdown
Member

Also, @redaranj we should review the iOS code for any similar issues... will try to get to that today.

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.

fix: OOM crash in handleSignFile due to ByteArrayStream loading entire file into memory

3 participants