Android: AppRTCMobile: Don't leak CallActivity.
Previously CallActivity would be leaked on every call. This CL fixes the problem. BUG=webrtc:6684 Review-Url: https://codereview.webrtc.org/2640433003 Cr-Commit-Position: refs/heads/master@{#16123}
This commit is contained in:
@ -346,7 +346,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
|
|||||||
peerConnectionClient.setPeerConnectionFactoryOptions(options);
|
peerConnectionClient.setPeerConnectionFactoryOptions(options);
|
||||||
}
|
}
|
||||||
peerConnectionClient.createPeerConnectionFactory(
|
peerConnectionClient.createPeerConnectionFactory(
|
||||||
CallActivity.this, peerConnectionParameters, CallActivity.this);
|
getApplicationContext(), peerConnectionParameters, CallActivity.this);
|
||||||
|
|
||||||
if (screencaptureEnabled) {
|
if (screencaptureEnabled) {
|
||||||
MediaProjectionManager mediaProjectionManager =
|
MediaProjectionManager mediaProjectionManager =
|
||||||
@ -434,6 +434,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler(null);
|
||||||
disconnect();
|
disconnect();
|
||||||
if (logToast != null) {
|
if (logToast != null) {
|
||||||
logToast.cancel();
|
logToast.cancel();
|
||||||
@ -530,7 +531,7 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
|
|||||||
|
|
||||||
// Create and audio manager that will take care of audio routing,
|
// Create and audio manager that will take care of audio routing,
|
||||||
// audio modes, audio device enumeration etc.
|
// audio modes, audio device enumeration etc.
|
||||||
audioManager = AppRTCAudioManager.create(this);
|
audioManager = AppRTCAudioManager.create(getApplicationContext());
|
||||||
// Store existing audio settings and change audio mode to
|
// Store existing audio settings and change audio mode to
|
||||||
// MODE_IN_COMMUNICATION for best possible VoIP performance.
|
// MODE_IN_COMMUNICATION for best possible VoIP performance.
|
||||||
Log.d(TAG, "Starting the audio manager...");
|
Log.d(TAG, "Starting the audio manager...");
|
||||||
|
|||||||
@ -92,7 +92,6 @@ public class PeerConnectionClient {
|
|||||||
private final SDPObserver sdpObserver = new SDPObserver();
|
private final SDPObserver sdpObserver = new SDPObserver();
|
||||||
private final ScheduledExecutorService executor;
|
private final ScheduledExecutorService executor;
|
||||||
|
|
||||||
private Context context;
|
|
||||||
private PeerConnectionFactory factory;
|
private PeerConnectionFactory factory;
|
||||||
private PeerConnection peerConnection;
|
private PeerConnection peerConnection;
|
||||||
PeerConnectionFactory.Options options = null;
|
PeerConnectionFactory.Options options = null;
|
||||||
@ -292,7 +291,6 @@ public class PeerConnectionClient {
|
|||||||
videoCallEnabled = peerConnectionParameters.videoCallEnabled;
|
videoCallEnabled = peerConnectionParameters.videoCallEnabled;
|
||||||
dataChannelEnabled = peerConnectionParameters.dataChannelParameters != null;
|
dataChannelEnabled = peerConnectionParameters.dataChannelParameters != null;
|
||||||
// Reset variables to initial states.
|
// Reset variables to initial states.
|
||||||
this.context = null;
|
|
||||||
factory = null;
|
factory = null;
|
||||||
peerConnection = null;
|
peerConnection = null;
|
||||||
preferIsac = false;
|
preferIsac = false;
|
||||||
@ -459,7 +457,6 @@ public class PeerConnectionClient {
|
|||||||
if (options != null) {
|
if (options != null) {
|
||||||
Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask);
|
Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMask);
|
||||||
}
|
}
|
||||||
this.context = context;
|
|
||||||
factory = new PeerConnectionFactory(options);
|
factory = new PeerConnectionFactory(options);
|
||||||
Log.d(TAG, "Peer connection factory created.");
|
Log.d(TAG, "Peer connection factory created.");
|
||||||
}
|
}
|
||||||
@ -639,6 +636,8 @@ public class PeerConnectionClient {
|
|||||||
videoSource.dispose();
|
videoSource.dispose();
|
||||||
videoSource = null;
|
videoSource = null;
|
||||||
}
|
}
|
||||||
|
localRender = null;
|
||||||
|
remoteRenders = null;
|
||||||
Log.d(TAG, "Closing peer connection factory.");
|
Log.d(TAG, "Closing peer connection factory.");
|
||||||
if (factory != null) {
|
if (factory != null) {
|
||||||
factory.dispose();
|
factory.dispose();
|
||||||
@ -649,6 +648,7 @@ public class PeerConnectionClient {
|
|||||||
events.onPeerConnectionClosed();
|
events.onPeerConnectionClosed();
|
||||||
PeerConnectionFactory.stopInternalTracingCapture();
|
PeerConnectionFactory.stopInternalTracingCapture();
|
||||||
PeerConnectionFactory.shutdownInternalTracer();
|
PeerConnectionFactory.shutdownInternalTracer();
|
||||||
|
events = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHDVideo() {
|
public boolean isHDVideo() {
|
||||||
|
|||||||
Reference in New Issue
Block a user