Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[Android] Fix resource leak when JitsiMeetView is destroyed
Saúl Ibarra Corretgébfa5f4c95306
diff --git a/android/README.md b/android/README.mdindex fe2a30049c..27eec01fdb 100644--- a/android/README.md+++ b/android/README.md@@ -56,6 +56,9 @@ public class MainActivity extends AppCompatActivity {protected void onDestroy() {super.onDestroy();+ view.dispose();+ view = null;+JitsiMeetView.onHostDestroy(this);}@@ -102,6 +105,12 @@ See JitsiMeetView.setWelcomePageEnabled.The `JitsiMeetView` class is the core of Jitsi Meet SDK. It's designed todisplay a Jitsi Meet conference (or a welcome page).+#### dispose()++Releases all resources associated with this view. This method MUST be called+when the Activity holding this view is going to be destroyed, usually in the+`onDestroy()` method.+#### getListener()Returns the `JitsiMeetViewListener` instance attached to the view.diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.javaindex d24f796a2b..87cf26a845 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java@@ -154,6 +154,11 @@ public class JitsiMeetActivity extends AppCompatActivity {protected void onDestroy() {super.onDestroy();+ if (view != null) {+ view.dispose();+ view = null;+ }+JitsiMeetView.onHostDestroy(this);}diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.javaindex b1a906d9ee..35e262ffb1 100644--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java@@ -199,6 +199,21 @@ public class JitsiMeetView extends FrameLayout {views.add(this);}+ /**+ * Releases the React resources (specifically the {@link ReactRootView})+ * associated with this view.+ *+ * This method MUST be called when the Activity holding this view is destroyed, typically in the+ * {@code onDestroy} method.+ */+ public void dispose() {+ if (reactRootView != null) {+ removeView(reactRootView);+ reactRootView.unmountReactApplication();+ reactRootView = null;+ }+ }+/*** Gets the {@link JitsiMeetViewListener} set on this {@code JitsiMeetView}.*@@ -257,10 +272,7 @@ public class JitsiMeetView extends FrameLayout {// TODO: ReactRootView#setAppProperties is only available on React// Native 0.45, so destroy the current root view and create a new one.- if (reactRootView != null) {- removeView(reactRootView);- reactRootView = null;- }+ dispose();reactRootView = new ReactRootView(getContext());reactRootView.startReactApplication(reactInstanceManager, "App", props);