Skip to content

Commit 0928e2d

Browse files
committed
[webview_flutter] Fix memory issue
Signed-off-by: MuHong Byun <[email protected]>
1 parent b2b2035 commit 0928e2d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/webview_flutter/tizen/src/webview.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,11 @@ void WebView::Dispose() {
393393
delete texture_variant_;
394394
texture_variant_ = nullptr;
395395
}
396+
397+
if (gpu_buffer_) {
398+
delete gpu_buffer_;
399+
gpu_buffer_ = nullptr;
400+
}
396401
}
397402

398403
void WebView::Resize(double width, double height) {
@@ -759,6 +764,10 @@ void WebView::InitWebView() {
759764
webview_instance_->Destroy();
760765
webview_instance_ = nullptr;
761766
}
767+
if (!gpu_buffer_) {
768+
gpu_buffer_ = new FlutterDesktopGpuBuffer();
769+
}
770+
762771
float scale_factor = 1;
763772

764773
webview_instance_ = (LWE::WebContainer*)createWebViewInstance(
@@ -925,10 +934,11 @@ FlutterDesktopGpuBuffer* WebView::CopyGpuBuffer(size_t width, size_t height) {
925934
rendered_surface_ = candidate_surface_;
926935
candidate_surface_ = nullptr;
927936

928-
FlutterDesktopGpuBuffer* gpu_buffer = new FlutterDesktopGpuBuffer();
929-
gpu_buffer->buffer = rendered_surface_;
930-
gpu_buffer->width = width;
931-
gpu_buffer->height = height;
937+
if (gpu_buffer_) {
938+
gpu_buffer->buffer = rendered_surface_;
939+
gpu_buffer->width = width;
940+
gpu_buffer->height = height;
941+
}
932942
return gpu_buffer;
933943
}
934944

packages/webview_flutter/tizen/src/webview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class WebView : public PlatformView {
7676
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> channel_;
7777
Ecore_IMF_Context* context_;
7878
flutter::TextureVariant* texture_variant_;
79+
FlutterDesktopGpuBuffer* gpu_buffer_;
7980
std::mutex mutex_;
8081
};
8182

0 commit comments

Comments
 (0)