@tiltio/capacitor-jitsi-meet 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -184,6 +184,9 @@ dedicated SDK event, check it against your deployment.
|
|
|
184
184
|
the PiP window would freeze. `JitsiAppStateGuard` intercepts `-[RCTAppState handleAppStateDidChange:]` and, during a
|
|
185
185
|
call with PiP, ignores the "will resign active" and "did enter background" notifications. Returning to the
|
|
186
186
|
foreground is passed through.
|
|
187
|
+
- **Memory.** Once the conference view is removed, the plugin frees the SDK's React Native runtime
|
|
188
|
+
(`destroyReactNative()`, as in the SDK samples), unless another conference opened meanwhile. The next `join`
|
|
189
|
+
recreates it.
|
|
187
190
|
|
|
188
191
|
### Android
|
|
189
192
|
|
|
@@ -192,6 +195,9 @@ dedicated SDK event, check it against your deployment.
|
|
|
192
195
|
- Events come from the SDK's local broadcasts (`BroadcastEvent`). `leave()` sends the SDK's hang-up broadcast and waits
|
|
193
196
|
for `READY_TO_CLOSE` (3 s max), so a conference opened right after isn't closed by the previous one.
|
|
194
197
|
- `expand()` brings `JitsiMeetActivity` back to the front if a call is in progress.
|
|
198
|
+
- **Memory.** Once `JitsiMeetActivity` is destroyed (not on a configuration change), the plugin frees the SDK's React
|
|
199
|
+
Native runtime (`JitsiMeet.destroyReactNative()`, as in the SDK samples), unless another conference opened
|
|
200
|
+
meanwhile. The next `join` recreates it.
|
|
195
201
|
|
|
196
202
|
## Limitations
|
|
197
203
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
package fr.tiltio.capacitor.jitsimeet;
|
|
2
2
|
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.app.Application;
|
|
3
5
|
import android.content.BroadcastReceiver;
|
|
4
6
|
import android.content.Context;
|
|
5
7
|
import android.content.Intent;
|
|
6
8
|
import android.content.IntentFilter;
|
|
9
|
+
import android.os.Bundle;
|
|
7
10
|
import android.os.Handler;
|
|
8
11
|
import android.os.Looper;
|
|
12
|
+
import androidx.annotation.NonNull;
|
|
9
13
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
10
14
|
import com.getcapacitor.JSObject;
|
|
11
15
|
import com.getcapacitor.Logger;
|
|
@@ -22,6 +26,7 @@ import java.util.Map;
|
|
|
22
26
|
import java.util.TreeSet;
|
|
23
27
|
import org.jitsi.meet.sdk.BroadcastEvent;
|
|
24
28
|
import org.jitsi.meet.sdk.BroadcastIntentHelper;
|
|
29
|
+
import org.jitsi.meet.sdk.JitsiMeet;
|
|
25
30
|
import org.jitsi.meet.sdk.JitsiMeetActivity;
|
|
26
31
|
import org.jitsi.meet.sdk.JitsiMeetConferenceOptions;
|
|
27
32
|
import org.jitsi.meet.sdk.JitsiMeetUserInfo;
|
|
@@ -75,6 +80,47 @@ public class JitsiMeetPlugin extends Plugin {
|
|
|
75
80
|
}
|
|
76
81
|
};
|
|
77
82
|
|
|
83
|
+
/** `JitsiMeetActivity` instances alive (created, not yet destroyed). Main thread only. */
|
|
84
|
+
private int jitsiActivities = 0;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Frees the SDK's React Native runtime once `JitsiMeetActivity` is gone, as the SDK samples do: it would otherwise
|
|
88
|
+
* stay in memory until the app is killed. The post runs after the activity's window detaches, which is when its
|
|
89
|
+
* `JitsiMeetView` gets disposed. Skipped when another conference opened meanwhile: it uses that runtime. The next
|
|
90
|
+
* `join` recreates it.
|
|
91
|
+
*/
|
|
92
|
+
private final Application.ActivityLifecycleCallbacks jitsiActivityCallbacks = new Application.ActivityLifecycleCallbacks() {
|
|
93
|
+
@Override
|
|
94
|
+
public void onActivityCreated(@NonNull Activity activity, Bundle savedInstanceState) {
|
|
95
|
+
if (activity instanceof JitsiMeetActivity) jitsiActivities++;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Override
|
|
99
|
+
public void onActivityDestroyed(@NonNull Activity activity) {
|
|
100
|
+
if (!(activity instanceof JitsiMeetActivity)) return;
|
|
101
|
+
jitsiActivities--;
|
|
102
|
+
if (activity.isChangingConfigurations()) return;
|
|
103
|
+
handler.post(() -> {
|
|
104
|
+
if (jitsiActivities == 0 && !inCall) JitsiMeet.destroyReactNative();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@Override
|
|
109
|
+
public void onActivityStarted(@NonNull Activity activity) {}
|
|
110
|
+
|
|
111
|
+
@Override
|
|
112
|
+
public void onActivityResumed(@NonNull Activity activity) {}
|
|
113
|
+
|
|
114
|
+
@Override
|
|
115
|
+
public void onActivityPaused(@NonNull Activity activity) {}
|
|
116
|
+
|
|
117
|
+
@Override
|
|
118
|
+
public void onActivityStopped(@NonNull Activity activity) {}
|
|
119
|
+
|
|
120
|
+
@Override
|
|
121
|
+
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {}
|
|
122
|
+
};
|
|
123
|
+
|
|
78
124
|
@Override
|
|
79
125
|
public void load() {
|
|
80
126
|
IntentFilter filter = new IntentFilter();
|
|
@@ -82,10 +128,12 @@ public class JitsiMeetPlugin extends Plugin {
|
|
|
82
128
|
filter.addAction(BroadcastEvent.Type.CONFERENCE_TERMINATED.getAction());
|
|
83
129
|
filter.addAction(BroadcastEvent.Type.READY_TO_CLOSE.getAction());
|
|
84
130
|
LocalBroadcastManager.getInstance(getContext()).registerReceiver(receiver, filter);
|
|
131
|
+
application().registerActivityLifecycleCallbacks(jitsiActivityCallbacks);
|
|
85
132
|
}
|
|
86
133
|
|
|
87
134
|
@Override
|
|
88
135
|
protected void handleOnDestroy() {
|
|
136
|
+
application().unregisterActivityLifecycleCallbacks(jitsiActivityCallbacks);
|
|
89
137
|
LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(receiver);
|
|
90
138
|
handler.removeCallbacksAndMessages(null);
|
|
91
139
|
resolvePendingLeaves();
|
|
@@ -123,11 +171,16 @@ public class JitsiMeetPlugin extends Plugin {
|
|
|
123
171
|
applyConfigOverrides(builder, call.getObject("configOverrides"));
|
|
124
172
|
builder.setFeatureFlag("pip.enabled", Boolean.TRUE.equals(call.getBoolean("pictureInPicture", true)));
|
|
125
173
|
|
|
126
|
-
|
|
174
|
+
// Before the launch: a runtime release still pending from the previous conference must not run.
|
|
127
175
|
inCall = true;
|
|
176
|
+
JitsiMeetActivity.launch(getContext(), builder.build());
|
|
128
177
|
call.resolve();
|
|
129
178
|
}
|
|
130
179
|
|
|
180
|
+
private Application application() {
|
|
181
|
+
return (Application) getContext().getApplicationContext();
|
|
182
|
+
}
|
|
183
|
+
|
|
131
184
|
/**
|
|
132
185
|
* Hangs up, and resolves only once the call screen is closed (`READY_TO_CLOSE`, or after `LEAVE_TIMEOUT_MS`): a
|
|
133
186
|
* conference opened right after must not be closed by this one.
|
|
@@ -164,14 +164,26 @@ public class JitsiMeetPlugin: CAPPlugin, CAPBridgedPlugin, JitsiMeetViewDelegate
|
|
|
164
164
|
if hangUp {
|
|
165
165
|
view.hangUp()
|
|
166
166
|
overlay.isHidden = true
|
|
167
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + Self.hangUpGrace) {
|
|
167
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + Self.hangUpGrace) { [weak self] in
|
|
168
168
|
overlay.removeFromSuperview()
|
|
169
|
+
self?.releaseReactNativeIfIdle()
|
|
169
170
|
}
|
|
170
171
|
} else {
|
|
171
172
|
overlay.removeFromSuperview()
|
|
173
|
+
releaseReactNativeIfIdle()
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Frees the SDK's React Native runtime once the conference view is gone, as the SDK samples do: it would otherwise
|
|
179
|
+
* stay in memory until the app is killed. Skipped when another conference opened meanwhile (joined during the
|
|
180
|
+
* hang-up grace): it uses that runtime. The next `join` recreates it.
|
|
181
|
+
*/
|
|
182
|
+
private func releaseReactNativeIfIdle() {
|
|
183
|
+
guard jitsiView == nil else { return }
|
|
184
|
+
JitsiMeet.sharedInstance().destroyReactNative()
|
|
185
|
+
}
|
|
186
|
+
|
|
175
187
|
/**
|
|
176
188
|
* Full-screen conference: status bar hidden and, with `lockPortraitOnPhone`, landscape allowed on iPhone.
|
|
177
189
|
* Otherwise (PiP, conference closed): status bar visible and, with `lockPortraitOnPhone`, back to portrait.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiltio/capacitor-jitsi-meet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Native full-screen Jitsi Meet conferences for Capacitor, with system Picture-in-Picture on iOS and Android.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|