Skip to content

Commit f7f878c

Browse files
committed
[webview_flutter] fix memory leak
Signed-off-by: MuHong Byun <[email protected]>
1 parent e36ea2f commit f7f878c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/webview_flutter/tizen/src/webview.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,11 @@ WebView::WebView(flutter::PluginRegistrar* registrar, int viewId,
168168
has_navigation_delegate_(false),
169169
has_progress_tracking_(false),
170170
context_(nullptr) {
171-
flutter::TextureVariant* textureVariant_ =
172-
new flutter::TextureVariant(flutter::GpuBufferTexture(
173-
[this](size_t width,
174-
size_t height) -> const FlutterDesktopGpuBuffer* {
175-
return this->CopyGpuBuffer(width, height);
176-
},
177-
[this](void* buffer) -> void { this->Destruction(buffer); }));
171+
textureVariant_ = new flutter::TextureVariant(flutter::GpuBufferTexture(
172+
[this](size_t width, size_t height) -> const FlutterDesktopGpuBuffer* {
173+
return this->CopyGpuBuffer(width, height);
174+
},
175+
[this](void* buffer) -> void { this->Destruction(buffer); }));
178176
SetTextureId(texture_registrar_->RegisterTexture(textureVariant_));
179177
InitWebView();
180178

@@ -390,6 +388,11 @@ void WebView::Dispose() {
390388
webview_instance_->Destroy();
391389
webview_instance_ = nullptr;
392390
}
391+
392+
if(textureVariant_) {
393+
delete textureVariant_;
394+
textureVariant_ = nullptr;
395+
}
393396
}
394397

395398
void WebView::Resize(double width, double height) {

packages/webview_flutter/tizen/src/webview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class WebView : public PlatformView {
7575
bool has_progress_tracking_;
7676
std::unique_ptr<flutter::MethodChannel<flutter::EncodableValue>> channel_;
7777
Ecore_IMF_Context* context_;
78+
flutter::TextureVariant* textureVariant_;
7879
std::mutex mutex_;
7980
};
8081

0 commit comments

Comments
 (0)