Commit 584479c9 authored by Narcis Beleuzu's avatar Narcis Beleuzu
Browse files

Backed out 19 changesets (bug 1830790) for mda failures on...

Backed out 19 changesets (bug 1830790) for mda failures on test_peerConnection_extmapRenegotiation.html and test_peerConnection_constructedStream.html . CLOSED TREE

Backed out changeset 6bba4358fd61 (bug 1830790)
Backed out changeset 78d17b4c904f (bug 1830790)
Backed out changeset b58ac93a466e (bug 1830790)
Backed out changeset fe902e60fec3 (bug 1830790)
Backed out changeset 212014a98617 (bug 1830790)
Backed out changeset 12d356a551fb (bug 1830790)
Backed out changeset 6ebddf918336 (bug 1830790)
Backed out changeset 0b361ee1fac2 (bug 1830790)
Backed out changeset 84935d63f443 (bug 1830790)
Backed out changeset bbd662a6d4f9 (bug 1830790)
Backed out changeset c9975073c8f9 (bug 1830790)
Backed out changeset 5ff45519f3c3 (bug 1830790)
Backed out changeset 74501c08f8e8 (bug 1830790)
Backed out changeset 174a610b9939 (bug 1830790)
Backed out changeset 7d67775baf45 (bug 1830790)
Backed out changeset f47f4c459184 (bug 1830790)
Backed out changeset 18e95d0700f7 (bug 1830790)
Backed out changeset de2dbc8d5e2a (bug 1830790)
Backed out changeset 887be68cd83e (bug 1830790)
parent 9662b871
Loading
Loading
Loading
Loading
+0 −209
Original line number Diff line number Diff line
@@ -53,16 +53,6 @@ let getStatsReports = async (filter = "") => {
  return reports;
};

const getStatsHistoryPcIds = async () => {
  return new Promise(r => WebrtcGlobalInformation.getStatsHistoryPcIds(r));
};

const getStatsHistorySince = async (pcid, after, sdpAfter) => {
  return new Promise(r =>
    WebrtcGlobalInformation.getStatsHistorySince(r, pcid, after, sdpAfter)
  );
};

let getLogging = async () => {
  let logs = await new Promise(r => WebrtcGlobalInformation.getLogging("", r));
  ok(Array.isArray(logs), "|logs| is an array");
@@ -283,202 +273,3 @@ add_task(async () => {
  await checkLoggingNonEmpty();
  await clearAndCheck();
});

const set_int_pref_returning_unsetter = (pref, num) => {
  const value = Services.prefs.getIntPref(pref);
  Services.prefs.setIntPref(pref, num);
  return () => Services.prefs.setIntPref(pref, value);
};

const stats_history_is_enabled = () => {
  return Services.prefs.getBoolPref("media.aboutwebrtc.hist.enabled");
};

const set_max_histories_to_retain = num =>
  set_int_pref_returning_unsetter(
    "media.aboutwebrtc.hist.closed_stats_to_retain",
    num
  );

const set_history_storage_window_s = num =>
  set_int_pref_returning_unsetter(
    "media.aboutwebrtc.hist.storage_window_s",
    num
  );

add_task(async () => {
  if (!stats_history_is_enabled()) {
    return;
  }
  info(
    "Test that stats history is available after close until clearLongTermStats is called"
  );
  await clearAndCheck();
  const pc = new RTCPeerConnection();

  const ids = await getStatsHistoryPcIds();
  is(ids.length, 1, "There is a single PeerConnection Id for stats history.");

  let firstLen = 0;
  // I "don't love" this but we don't have a anything we can await on ... yet.
  // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
  await new Promise(r => setTimeout(r, 2000));
  {
    const history = await getStatsHistorySince(ids[0]);
    firstLen = history.reports.length;
    ok(
      history.reports.length,
      "There is at least a single PeerConnection stats history before close."
    );
  }
  // I "don't love" this but we don't have a anything we can await on ... yet.
  // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
  await new Promise(r => setTimeout(r, 2000));
  {
    const history = await getStatsHistorySince(ids[0]);
    const secondLen = history.reports.length;
    ok(
      secondLen > firstLen,
      "After waiting there are more history entries available."
    );
  }
  pc.close();
  // After close for final stats and pc teardown to settle
  // I "don't love" this but we don't have a anything we can await on ... yet.
  // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
  await new Promise(r => setTimeout(r, 2000));
  {
    const history = await getStatsHistorySince(ids[0]);
    ok(
      history.reports.length,
      "There is at least a single PeerConnection stats history after close."
    );
  }
  await clearAndCheck();
  {
    const history = await getStatsHistorySince(ids[0]);
    is(
      history.reports.length,
      0,
      "After PC.close and clearing the stats there are no history reports"
    );
  }
  {
    const ids1 = await getStatsHistoryPcIds();
    is(
      ids1.length,
      0,
      "After PC.close and clearing the stats there are no history pcids"
    );
  }
  {
    const pc2 = new RTCPeerConnection();
    const pc3 = new RTCPeerConnection();
    let idsN = await getStatsHistoryPcIds();
    is(
      idsN.length,
      2,
      "There are two pcIds after creating two PeerConnections"
    );
    pc2.close();
    // After close for final stats and pc teardown to settle
    // I "don't love" this but we don't have a anything we can await on ... yet.
    // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
    await new Promise(r => setTimeout(r, 2000));
    await WebrtcGlobalInformation.clearAllStats();
    idsN = await getStatsHistoryPcIds();
    is(
      idsN.length,
      1,
      "There is one pcIds after closing one of two PeerConnections and clearing stats"
    );
    pc3.close();
    // After close for final stats and pc teardown to settle
    // I "don't love" this but we don't have a anything we can await on ... yet.
    // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
    await new Promise(r => setTimeout(r, 2000));
  }
});

add_task(async () => {
  if (!stats_history_is_enabled()) {
    return;
  }
  const restoreHistRetainPref = set_max_histories_to_retain(7);
  info("Test that the proper number of pcIds are available");
  await clearAndCheck();
  const pc01 = new RTCPeerConnection();
  const pc02 = new RTCPeerConnection();
  const pc03 = new RTCPeerConnection();
  const pc04 = new RTCPeerConnection();
  const pc05 = new RTCPeerConnection();
  const pc06 = new RTCPeerConnection();
  const pc07 = new RTCPeerConnection();
  const pc08 = new RTCPeerConnection();
  const pc09 = new RTCPeerConnection();
  const pc10 = new RTCPeerConnection();
  const pc11 = new RTCPeerConnection();
  const pc12 = new RTCPeerConnection();
  const pc13 = new RTCPeerConnection();
  // I "don't love" this but we don't have a anything we can await on ... yet.
  // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
  await new Promise(r => setTimeout(r, 2000));
  {
    const ids = await getStatsHistoryPcIds();
    is(ids.length, 13, "There is are 13 PeerConnection Ids for stats history.");
  }
  pc01.close();
  pc02.close();
  pc03.close();
  pc04.close();
  pc05.close();
  pc06.close();
  pc07.close();
  pc08.close();
  pc09.close();
  pc10.close();
  pc11.close();
  pc12.close();
  pc13.close();
  // I "don't love" this but we don't have a anything we can await on ... yet.
  // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
  await new Promise(r => setTimeout(r, 2000));
  {
    const ids = await getStatsHistoryPcIds();
    is(
      ids.length,
      7,
      "After closing 13 PCs there are no more than the max closed (7) PeerConnection Ids for stats history."
    );
  }
  restoreHistRetainPref();
  await clearAndCheck();
});

add_task(async () => {
  if (!stats_history_is_enabled()) {
    return;
  }
  // If you change this, please check if the setTimeout should be updated.
  // NOTE: the unit here is _integer_ seconds.
  const STORAGE_WINDOW_S = 1;
  const restoreStorageWindowPref =
    set_history_storage_window_s(STORAGE_WINDOW_S);
  info("Test that history items are being aged out");
  await clearAndCheck();
  const pc = new RTCPeerConnection();
  // I "don't love" this but we don't have a anything we can await on ... yet.
  // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
  await new Promise(r => setTimeout(r, STORAGE_WINDOW_S * 2 * 1000));
  const ids = await getStatsHistoryPcIds();
  const { reports } = await getStatsHistorySince(ids[0]);
  const first = reports[0];
  const last = reports.at(-1);
  ok(
    last.timestamp - first.timestamp <= STORAGE_WINDOW_S * 1000,
    "History reports should be aging out according to the storage window pref"
  );
  pc.close();
  restoreStorageWindowPref();
  await clearAndCheck();
});
+0 −3
Original line number Diff line number Diff line
@@ -21,9 +21,6 @@ async protocol PWebrtcGlobal {
parent: // child -> parent messages
  async __delete__();
#ifdef MOZ_WEBRTC
  async PeerConnectionCreated(nsString aPcId, bool aIsLongTermStatsDisabled);
  async PeerConnectionDestroyed(nsString aPcId);
  async PeerConnectionFinalStats(RTCStatsReportInternal aFinalStats);

child: // parent -> child messages
  async GetStats(nsString aPcIdFilter) returns (RTCStatsReportInternal[] stats);
+2 −2
Original line number Diff line number Diff line
@@ -119,8 +119,8 @@ struct ParamTraits<mozilla::dom::RTCStatsCollection> {

DEFINE_IPC_SERIALIZER_WITH_SUPER_CLASS_AND_FIELDS(
    mozilla::dom::RTCStatsReportInternal, mozilla::dom::RTCStatsCollection,
    mClosed, mSdpHistory, mPcid, mBrowserId, mTimestamp, mCallDurationMs,
    mIceRestarts, mIceRollbacks, mOfferer, mConfiguration);
    mClosed, mLocalSdp, mSdpHistory, mPcid, mBrowserId, mRemoteSdp, mTimestamp,
    mCallDurationMs, mIceRestarts, mIceRollbacks, mOfferer, mConfiguration);

typedef mozilla::dom::RTCStats RTCStats;

+2 −31
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@

#include "PeerConnectionCtx.h"

#include "WebrtcGlobalStatsHistory.h"
#include "api/audio/audio_mixer.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "modules/rtp_rtcp/source/rtp_header_extensions.h"
@@ -17,14 +16,12 @@
#include "modules/audio_device/include/fake_audio_device.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "modules/audio_processing/include/aec_dump.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/RTCPeerConnectionBinding.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Types.h"
#include "mozilla/dom/RTCStatsReportBinding.h"
#include "nsCRTGlue.h"
#include "nsIIOService.h"
#include "nsIObserver.h"
@@ -433,23 +430,9 @@ void PeerConnectionCtx::RemovePeerConnection(const std::string& aKey) {
    if (it->second->GetFinalStats() && !it->second->LongTermStatsIsDisabled()) {
      WebrtcGlobalInformation::StashStats(*(it->second->GetFinalStats()));
    }
    nsAutoString pcId = NS_ConvertASCIItoUTF16(it->second->GetName().c_str());
    if (XRE_IsContentProcess()) {
      if (auto* child = WebrtcGlobalChild::Get(); child) {
        auto pcId = NS_ConvertASCIItoUTF16(it->second->GetName().c_str());
        child->SendPeerConnectionFinalStats(*(it->second->GetFinalStats()));
        child->SendPeerConnectionDestroyed(pcId);
      }
    } else {
      using Update = WebrtcGlobalInformation::PcTrackingUpdate;
      auto update = Update::Remove(pcId);
      auto finalStats =
          MakeUnique<RTCStatsReportInternal>(*(it->second->GetFinalStats()));
      WebrtcGlobalStatsHistory::Record(std::move(finalStats));
      WebrtcGlobalInformation::PeerConnectionTracking(update);
    }

    mPeerConnections.erase(it);

    if (mPeerConnections.empty()) {
      mSharedWebrtcState = nullptr;
      StopTelemetryTimer();
@@ -496,17 +479,6 @@ void PeerConnectionCtx::AddPeerConnection(const std::string& aKey,
        std::move(trials));
    StartTelemetryTimer();
  }
  auto pcId = NS_ConvertASCIItoUTF16(aPeerConnection->GetName().c_str());
  if (XRE_IsContentProcess()) {
    if (auto* child = WebrtcGlobalChild::Get(); child) {
      child->SendPeerConnectionCreated(
          pcId, aPeerConnection->LongTermStatsIsDisabled());
    }
  } else {
    using Update = WebrtcGlobalInformation::PcTrackingUpdate;
    auto update = Update::Add(pcId, aPeerConnection->LongTermStatsIsDisabled());
    WebrtcGlobalInformation::PeerConnectionTracking(update);
  }
  mPeerConnections[aKey] = aPeerConnection;
}

@@ -531,13 +503,12 @@ void PeerConnectionCtx::ClearClosedStats() {
}

nsresult PeerConnectionCtx::Initialize() {
  MOZ_ASSERT(NS_IsMainThread());
  initGMP();
  SdpRidAttributeList::kMaxRidLength =
      webrtc::BaseRtpStringExtension::kMaxValueSizeBytes;

  if (XRE_IsContentProcess()) {
    WebrtcGlobalChild::Get();
    WebrtcGlobalChild::Create();
  }

  return NS_OK;
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
#include <map>
#include <string>

#include "WebrtcGlobalChild.h"
#include "api/field_trials_view.h"
#include "api/scoped_refptr.h"
#include "call/audio_state.h"
Loading