Skip to content
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

[iOS] composition items memory issue #8

Open
jinookoo opened this issue Aug 23, 2024 · 3 comments
Open

[iOS] composition items memory issue #8

jinookoo opened this issue Aug 23, 2024 · 3 comments

Comments

@jinookoo
Copy link
Contributor

in FramesExtrator, Exporter
initialize 'VideoCompositionItemDecoder' at once
So, If a lot of items make OOM crash.
This problem can be solved by using decoder pool only for required items
Then I can preview a lot of composition items.

However, the frame generation loop in the exporter still has memory issues.
If you are using 'Instructions' for monitoring memory allocation.
It continues to increase until it is finished.
so short composition items will be fine but long & heavy video have same problem.

CVPixelBufferCreate return kCVReturnAllocationFailed
create MTLTexture return null

But It already been called

CVPixelBufferRelease(pixelBuffer);
[cpuAccessibleTexture setPurgeableState:MTLPurgeableStateEmpty];

Can anyone help me with this?

@jinookoo
Copy link
Contributor Author

@fdecampredon 🥹

@fdecampredon
Copy link
Contributor

fdecampredon commented Aug 26, 2024

For preview, the problem with using VideoCompositionItemDecoder on demand is for live composition playing. for example let's say you need to play a video at frame 60, if we don't pre-create the decoder it might not be ready in time.

For export, we'll try to investigate memory issue, but in general most of the memory allocated is done by AVAssetReader, which we don't have the control over.
However, we could use lazy VideoCompositionItemDecoder creation.

Just for info are you using the resolution field in your composition item ? Downscaling the resolution has a great impact on memory issues.

@jinookoo
Copy link
Contributor Author

Oh, I'm missing 'resolution' in composition item. It pretty good for better preview.

But it still have many composition items will load at once.

How about initialize items will renderer by compositionStartTime, startTime, duration.
Here is PR

and exporting memory allocation fixed PR

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

No branches or pull requests

2 participants