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

Add a release method to PAGViewController and PAGImageViewController to support immediate memory release when called externally. #2644

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ohos/libpag/src/main/ets/PAGImageView.ets
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ export class PAGImageViewController {
this.view = null;
}

/**
* Free up resources used by the PAGImageViewController instance immediately instead of relying on the
* garbage collector to do this for you at some point in the future.
*/
release() {
this.jImageView.release();
}

private composition: PAGComposition | null = null;
private filePath: string | null = null;
private listeners: Array<WeakRef<PAGImageViewListener>> = [];
Expand Down
8 changes: 8 additions & 0 deletions ohos/libpag/src/main/ets/PAGView.ets
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ export class PAGViewController {
this.view = null;
}

/**
* Free up resources used by the PAGViewController instance immediately instead of relying on the
* garbage collector to do this for you at some point in the future.
*/
release() {
this.jView.release();
}

uniqueID() {
return this.jView.uniqueID();
}
Expand Down
3 changes: 2 additions & 1 deletion src/platform/ohos/OHOSVideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ OHOSVideoDecoder::~OHOSVideoDecoder() {
videoCodec = nullptr;
}
if (codecUserData) {
codecUserData->clearQueue();
delete codecUserData;
}
}
Expand Down Expand Up @@ -271,6 +272,7 @@ std::shared_ptr<tgfx::ImageBuffer> OHOSVideoDecoder::onRenderFrame() {
if (format) {
OH_AVFormat_GetIntValue(format, OH_MD_KEY_VIDEO_STRIDE, &videoStride);
OH_AVFormat_GetIntValue(format, OH_MD_KEY_VIDEO_SLICE_HEIGHT, &videoSliceHeight);
OH_AVFormat_Destroy(format);
}
if (videoStride == 0 || videoSliceHeight == 0) {
return nullptr;
Expand All @@ -291,7 +293,6 @@ std::shared_ptr<tgfx::ImageBuffer> OHOSVideoDecoder::onRenderFrame() {
}
yuvBuffer->lineSize[0] = videoStride;
yuvBuffer->lineSize[1] = videoStride;
OH_AVFormat_Destroy(format);
}
auto capacity = OH_AVBuffer_GetCapacity(codecBufferInfo.buffer);
if (capacity <= 0) {
Expand Down
Loading