diff --git a/content/media/webrtc/MediaEngineWebRTC.cpp b/content/media/webrtc/MediaEngineWebRTC.cpp index a6e34d5e2334..596b9848af38 100644 --- a/content/media/webrtc/MediaEngineWebRTC.cpp +++ b/content/media/webrtc/MediaEngineWebRTC.cpp @@ -34,6 +34,7 @@ GetUserMediaLog() #include "nsITabSource.h" #ifdef MOZ_WIDGET_ANDROID +#include "AndroidJNIWrapper.h" #include "AndroidBridge.h" #endif @@ -250,16 +251,12 @@ MediaEngineWebRTC::EnumerateAudioDevices(nsTArrayGetVM(); - - JNIEnv *env; - jvm->AttachCurrentThread(&env, nullptr); + JNIEnv *env = GetJNIForThread(); if (webrtc::VoiceEngine::SetAndroidObjects(jvm, env, (void*)context) != 0) { LOG(("VoiceEngine:SetAndroidObjects Failed")); return; } - - env->DeleteGlobalRef(context); #endif if (!mVoiceEngine) {