Skip to content

Commit b8005fe

Browse files
author
agoloman
committed
Revert "Bug 1868223 - Reenable WPT RTCRtpScriptTransform-sender-worker-single-frame.https.html. r=bwc" for causing ios build bustages @StructuredCloneHolder.cpp.
This reverts commit 7988aa9. Revert "Bug 1868223 - Implement custom RTCEncodedAudioFrame::Read/WriteStructuredClone for same process. r=bwc" This reverts commit e37d4c6. Revert "Bug 1868223 - Implement custom RTCEncodedVideoFrame::Read/WriteStructuredClone for same process. r=bwc,webidl,smaug" This reverts commit 17b8e79. Revert "Bug 1868223 - Add moz.build files from updated BUILD.gn r=mjf" This reverts commit 5c0daa9. Revert "Bug 1868223 - Add api:frame_transformer_factory to BUILD.gn r=mjf" This reverts commit 84bd006.
1 parent dafda85 commit b8005fe

16 files changed

Lines changed: 67 additions & 630 deletions

dom/base/StructuredCloneHolder.cpp

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "mozilla/RefPtr.h"
2323
#include "mozilla/ScopeExit.h"
2424
#include "mozilla/StaticPrefs_dom.h"
25-
#include "mozilla/StaticPrefs_media.h"
2625
#include "mozilla/dom/AudioData.h"
2726
#include "mozilla/dom/BindingDeclarations.h"
2827
#include "mozilla/dom/BindingUtils.h"
@@ -53,10 +52,6 @@
5352
#include "mozilla/dom/MessagePortBinding.h"
5453
#include "mozilla/dom/OffscreenCanvas.h"
5554
#include "mozilla/dom/OffscreenCanvasBinding.h"
56-
#include "mozilla/dom/RTCEncodedAudioFrame.h"
57-
#include "mozilla/dom/RTCEncodedAudioFrameBinding.h"
58-
#include "mozilla/dom/RTCEncodedVideoFrame.h"
59-
#include "mozilla/dom/RTCEncodedVideoFrameBinding.h"
6055
#include "mozilla/dom/ReadableStream.h"
6156
#include "mozilla/dom/ReadableStreamBinding.h"
6257
#include "mozilla/dom/ScriptSettings.h"
@@ -1160,28 +1155,6 @@ JSObject* StructuredCloneHolder::CustomReadHandler(
11601155
}
11611156
}
11621157

1163-
if (StaticPrefs::media_peerconnection_enabled() &&
1164-
aTag == SCTAG_DOM_RTCENCODEDVIDEOFRAME &&
1165-
CloneScope() == StructuredCloneScope::SameProcess &&
1166-
aCloneDataPolicy.areIntraClusterClonableSharedObjectsAllowed()) {
1167-
JS::Rooted<JSObject*> global(aCx, mGlobal->GetGlobalJSObject());
1168-
if (RTCEncodedVideoFrame_Binding::ConstructorEnabled(aCx, global)) {
1169-
return RTCEncodedVideoFrame::ReadStructuredClone(
1170-
aCx, mGlobal, aReader, RtcEncodedVideoFrames()[aIndex]);
1171-
}
1172-
}
1173-
1174-
if (StaticPrefs::media_peerconnection_enabled() &&
1175-
aTag == SCTAG_DOM_RTCENCODEDAUDIOFRAME &&
1176-
CloneScope() == StructuredCloneScope::SameProcess &&
1177-
aCloneDataPolicy.areIntraClusterClonableSharedObjectsAllowed()) {
1178-
JS::Rooted<JSObject*> global(aCx, mGlobal->GetGlobalJSObject());
1179-
if (RTCEncodedAudioFrame_Binding::ConstructorEnabled(aCx, global)) {
1180-
return RTCEncodedAudioFrame::ReadStructuredClone(
1181-
aCx, mGlobal, aReader, RtcEncodedAudioFrames()[aIndex]);
1182-
}
1183-
}
1184-
11851158
return ReadFullySerializableObjects(aCx, aReader, aTag, false);
11861159
}
11871160

@@ -1324,28 +1297,6 @@ bool StructuredCloneHolder::CustomWriteHandler(
13241297
}
13251298
}
13261299

1327-
// See if this is an RTCEncodedVideoFrame object.
1328-
if (StaticPrefs::media_peerconnection_enabled()) {
1329-
RTCEncodedVideoFrame* rtcFrame = nullptr;
1330-
if (NS_SUCCEEDED(UNWRAP_OBJECT(RTCEncodedVideoFrame, &obj, rtcFrame))) {
1331-
SameProcessScopeRequired(aSameProcessScopeRequired);
1332-
return CloneScope() == StructuredCloneScope::SameProcess
1333-
? rtcFrame->WriteStructuredClone(aWriter, this)
1334-
: false;
1335-
}
1336-
}
1337-
1338-
// See if this is an RTCEncodedAudioFrame object.
1339-
if (StaticPrefs::media_peerconnection_enabled()) {
1340-
RTCEncodedAudioFrame* rtcFrame = nullptr;
1341-
if (NS_SUCCEEDED(UNWRAP_OBJECT(RTCEncodedAudioFrame, &obj, rtcFrame))) {
1342-
SameProcessScopeRequired(aSameProcessScopeRequired);
1343-
return CloneScope() == StructuredCloneScope::SameProcess
1344-
? rtcFrame->WriteStructuredClone(aWriter, this)
1345-
: false;
1346-
}
1347-
}
1348-
13491300
{
13501301
// We only care about streams, so ReflectorToISupportsStatic is fine.
13511302
nsCOMPtr<nsISupports> base = xpc::ReflectorToISupportsStatic(aObj);

dom/base/StructuredCloneHolder.h

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,6 @@ class MessagePort;
172172
class MessagePortIdentifier;
173173
struct VideoFrameSerializedData;
174174
struct AudioDataSerializedData;
175-
struct RTCEncodedVideoFrameData;
176-
struct RTCEncodedAudioFrameData;
177175

178176
class StructuredCloneHolder : public StructuredCloneHolderBase {
179177
public:
@@ -216,17 +214,15 @@ class StructuredCloneHolder : public StructuredCloneHolderBase {
216214
// Create a statement for each of the side DOM-ish data members.
217215
// mTransferredPorts is not included because it is part of the
218216
// deserialized state.
219-
#define CLONED_DATA_MEMBERS \
220-
STMT(mBlobImplArray); \
221-
STMT(mWasmModuleArray); \
222-
STMT(mInputStreamArray); \
223-
STMT(mClonedSurfaces); \
224-
STMT(mVideoFrames); \
225-
STMT(mAudioData); \
226-
STMT(mEncodedVideoChunks); \
227-
STMT(mEncodedAudioChunks); \
228-
STMT(mRtcEncodedVideoFrames); \
229-
STMT(mRtcEncodedAudioFrames); \
217+
#define CLONED_DATA_MEMBERS \
218+
STMT(mBlobImplArray); \
219+
STMT(mWasmModuleArray); \
220+
STMT(mInputStreamArray); \
221+
STMT(mClonedSurfaces); \
222+
STMT(mVideoFrames); \
223+
STMT(mAudioData); \
224+
STMT(mEncodedVideoChunks); \
225+
STMT(mEncodedAudioChunks); \
230226
STMT(mPortIdentifiers);
231227

232228
// Call this method to know if this object is keeping some DOM object alive.
@@ -306,14 +302,6 @@ class StructuredCloneHolder : public StructuredCloneHolderBase {
306302
return mEncodedAudioChunks;
307303
}
308304

309-
nsTArray<RTCEncodedVideoFrameData>& RtcEncodedVideoFrames() {
310-
return mRtcEncodedVideoFrames;
311-
}
312-
313-
nsTArray<RTCEncodedAudioFrameData>& RtcEncodedAudioFrames() {
314-
return mRtcEncodedAudioFrames;
315-
}
316-
317305
// Implementations of the virtual methods to allow cloning of objects which
318306
// JS engine itself doesn't clone.
319307

@@ -428,12 +416,6 @@ class StructuredCloneHolder : public StructuredCloneHolderBase {
428416
// Used for cloning EncodedAudioChunk in the structured cloning algorithm.
429417
nsTArray<EncodedAudioChunkData> mEncodedAudioChunks;
430418

431-
// Used for cloning RTCEncodedVideoFrame in the structured cloning algorithm.
432-
nsTArray<RTCEncodedVideoFrameData> mRtcEncodedVideoFrames;
433-
434-
// Used for cloning RTCEncodedAudioFrame in the structured cloning algorithm.
435-
nsTArray<RTCEncodedAudioFrameData> mRtcEncodedAudioFrames;
436-
437419
// This raw pointer is only set within ::Read() and is unset by the end.
438420
nsIGlobalObject* MOZ_NON_OWNING_REF mGlobal;
439421

dom/base/StructuredCloneTags.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ enum StructuredCloneTags : uint32_t {
163163

164164
SCTAG_DOM_RTCDATACHANNEL,
165165

166-
SCTAG_DOM_RTCENCODEDVIDEOFRAME,
167-
168-
SCTAG_DOM_RTCENCODEDAUDIOFRAME,
169-
170166
// IMPORTANT: If you plan to add an new IDB tag, it _must_ be add before the
171167
// "less stable" tags!
172168
};

dom/media/webrtc/jsapi/RTCEncodedAudioFrame.cpp

Lines changed: 3 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <memory>
1212
#include <utility>
1313

14-
#include "api/frame_transformer_factory.h"
1514
#include "api/frame_transformer_interface.h"
1615
#include "js/RootingAPI.h"
1716
#include "jsapi/RTCEncodedFrameBase.h"
@@ -21,8 +20,6 @@
2120
#include "mozilla/Unused.h"
2221
#include "mozilla/dom/RTCEncodedAudioFrameBinding.h"
2322
#include "mozilla/dom/RTCRtpScriptTransformer.h"
24-
#include "mozilla/dom/StructuredCloneHolder.h"
25-
#include "mozilla/dom/StructuredCloneTags.h"
2623
#include "mozilla/fallible.h"
2724
#include "nsContentUtils.h"
2825
#include "nsCycleCollectionParticipant.h"
@@ -32,20 +29,8 @@
3229

3330
namespace mozilla::dom {
3431

35-
NS_IMPL_CYCLE_COLLECTION_CLASS(RTCEncodedAudioFrame)
36-
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(RTCEncodedAudioFrame,
37-
RTCEncodedFrameBase)
38-
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
39-
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
40-
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
41-
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(RTCEncodedAudioFrame,
42-
RTCEncodedFrameBase)
43-
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
44-
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
45-
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(RTCEncodedAudioFrame,
46-
RTCEncodedFrameBase)
47-
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
48-
NS_IMPL_CYCLE_COLLECTION_TRACE_END
32+
NS_IMPL_CYCLE_COLLECTION_INHERITED(RTCEncodedAudioFrame, RTCEncodedFrameBase,
33+
mOwner)
4934
NS_IMPL_ADDREF_INHERITED(RTCEncodedAudioFrame, RTCEncodedFrameBase)
5035
NS_IMPL_RELEASE_INHERITED(RTCEncodedAudioFrame, RTCEncodedFrameBase)
5136

@@ -57,8 +42,7 @@ RTCEncodedAudioFrame::RTCEncodedAudioFrame(
5742
nsIGlobalObject* aGlobal,
5843
std::unique_ptr<webrtc::TransformableFrameInterface> aFrame,
5944
uint64_t aCounter, RTCRtpScriptTransformer* aOwner)
60-
: RTCEncodedAudioFrameData{{std::move(aFrame), aCounter, /*timestamp*/ 0}},
61-
RTCEncodedFrameBase(aGlobal, static_cast<RTCEncodedFrameState&>(*this)),
45+
: RTCEncodedFrameBase(aGlobal, std::move(aFrame), aCounter),
6246
mOwner(aOwner) {
6347
mMetadata.mSynchronizationSource.Construct(mFrame->GetSsrc());
6448
mMetadata.mPayloadType.Construct(mFrame->GetPayloadType());
@@ -78,22 +62,7 @@ RTCEncodedAudioFrame::RTCEncodedAudioFrame(
7862
mozilla::HoldJSObjects(this);
7963
}
8064

81-
RTCEncodedAudioFrame::RTCEncodedAudioFrame(nsIGlobalObject* aGlobal,
82-
RTCEncodedAudioFrameData&& aData)
83-
: RTCEncodedAudioFrameData{{std::move(aData.mFrame), aData.mCounter,
84-
aData.mTimestamp},
85-
std::move(aData.mMetadata)},
86-
RTCEncodedFrameBase(aGlobal, static_cast<RTCEncodedFrameState&>(*this)),
87-
mOwner(nullptr) {
88-
// Base class needs this, but can't do it itself because of an assertion in
89-
// the cycle-collector.
90-
mozilla::HoldJSObjects(this);
91-
}
92-
9365
RTCEncodedAudioFrame::~RTCEncodedAudioFrame() {
94-
// Clear JS::Heap<> members before unregistering as a script holder,
95-
// so their destructors don't barrier against a finalized JS object.
96-
mData = nullptr; // from RTCEncodedFrameBase (protected)
9766
// Base class needs this, but can't do it itself because of an assertion in
9867
// the cycle-collector.
9968
mozilla::DropJSObjects(this);
@@ -104,14 +73,6 @@ JSObject* RTCEncodedAudioFrame::WrapObject(JSContext* aCx,
10473
return RTCEncodedAudioFrame_Binding::Wrap(aCx, this, aGivenProto);
10574
}
10675

107-
RTCEncodedAudioFrameData RTCEncodedAudioFrameData::Clone() const {
108-
return RTCEncodedAudioFrameData{
109-
{webrtc::CloneAudioFrame(
110-
static_cast<webrtc::TransformableAudioFrameInterface*>(
111-
mFrame.get()))},
112-
RTCEncodedAudioFrameMetadata(mMetadata)};
113-
}
114-
11576
nsIGlobalObject* RTCEncodedAudioFrame::GetParentObject() const {
11677
return mGlobal;
11778
}
@@ -124,43 +85,4 @@ void RTCEncodedAudioFrame::GetMetadata(
12485
bool RTCEncodedAudioFrame::CheckOwner(RTCRtpScriptTransformer* aOwner) const {
12586
return aOwner == mOwner;
12687
}
127-
128-
// https://www.w3.org/TR/webrtc-encoded-transform/#RTCEncodedAudioFrame-serialization
129-
/* static */
130-
JSObject* RTCEncodedAudioFrame::ReadStructuredClone(
131-
JSContext* aCx, nsIGlobalObject* aGlobal, JSStructuredCloneReader* aReader,
132-
RTCEncodedAudioFrameData& aData) {
133-
JS::Rooted<JS::Value> value(aCx, JS::NullValue());
134-
// To avoid a rooting hazard error from returning a raw JSObject* before
135-
// running the RefPtr destructor, RefPtr needs to be destructed before
136-
// returning the raw JSObject*, which is why the RefPtr<RTCEncodedAudioFrame>
137-
// is created in the scope below. Otherwise, the static analysis infers the
138-
// RefPtr cannot be safely destructed while the unrooted return JSObject* is
139-
// on the stack.
140-
{
141-
auto frame = MakeRefPtr<RTCEncodedAudioFrame>(aGlobal, std::move(aData));
142-
if (!GetOrCreateDOMReflector(aCx, frame, &value) || !value.isObject()) {
143-
return nullptr;
144-
}
145-
}
146-
return value.toObjectOrNull();
147-
}
148-
149-
bool RTCEncodedAudioFrame::WriteStructuredClone(
150-
JSStructuredCloneWriter* aWriter, StructuredCloneHolder* aHolder) const {
151-
AssertIsOnOwningThread();
152-
153-
// Indexing the chunk and send the index to the receiver.
154-
const uint32_t index =
155-
static_cast<uint32_t>(aHolder->RtcEncodedAudioFrames().Length());
156-
// The serialization is limited to the same process scope so it's ok to
157-
// hand over a (copy of a) webrtc internal object here.
158-
//
159-
// TODO: optimize later once encoded source API materializes
160-
// .AppendElement(aHolder->IsTransferred(mData) ? Take() : Clone())
161-
aHolder->RtcEncodedAudioFrames().AppendElement(Clone());
162-
return !NS_WARN_IF(
163-
!JS_WriteUint32Pair(aWriter, SCTAG_DOM_RTCENCODEDAUDIOFRAME, index));
164-
}
165-
16688
} // namespace mozilla::dom

dom/media/webrtc/jsapi/RTCEncodedAudioFrame.h

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,28 @@
77
#ifndef MOZILLA_DOM_MEDIA_WEBRTC_JSAPI_RTCENCODEDAUDIOFRAME_H_
88
#define MOZILLA_DOM_MEDIA_WEBRTC_JSAPI_RTCENCODEDAUDIOFRAME_H_
99

10+
#include "jsapi/RTCEncodedFrameBase.h"
1011
#include "mozilla/RefPtr.h"
1112
#include "mozilla/dom/RTCEncodedAudioFrameBinding.h"
12-
#include "mozilla/dom/RTCEncodedFrameBase.h"
1313
#include "nsIGlobalObject.h"
1414

1515
namespace mozilla::dom {
1616

17-
class StructuredCloneHolder;
18-
19-
struct RTCEncodedAudioFrameData : RTCEncodedFrameState {
20-
RTCEncodedAudioFrameMetadata mMetadata;
21-
22-
[[nodiscard]] RTCEncodedAudioFrameData Clone() const;
23-
};
24-
2517
// Wraps a libwebrtc frame, allowing the frame buffer to be modified, and
2618
// providing read-only access to various metadata. After the libwebrtc frame is
2719
// extracted (with RTCEncodedFrameBase::TakeFrame), the frame buffer is
2820
// detached, but the metadata remains accessible.
29-
class RTCEncodedAudioFrame final : public RTCEncodedAudioFrameData,
30-
public RTCEncodedFrameBase {
21+
class RTCEncodedAudioFrame final : public RTCEncodedFrameBase {
3122
public:
3223
explicit RTCEncodedAudioFrame(
3324
nsIGlobalObject* aGlobal,
3425
std::unique_ptr<webrtc::TransformableFrameInterface> aFrame,
3526
uint64_t aCounter, RTCRtpScriptTransformer* aOwner);
3627

37-
explicit RTCEncodedAudioFrame(nsIGlobalObject* aGlobal,
38-
RTCEncodedAudioFrameData&& aData);
39-
4028
// nsISupports
4129
NS_DECL_ISUPPORTS_INHERITED
42-
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(RTCEncodedAudioFrame,
43-
RTCEncodedFrameBase)
30+
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RTCEncodedAudioFrame,
31+
RTCEncodedFrameBase)
4432

4533
// webidl (timestamp and data accessors live in base class)
4634
JSObject* WrapObject(JSContext* aCx,
@@ -54,27 +42,10 @@ class RTCEncodedAudioFrame final : public RTCEncodedAudioFrameData,
5442

5543
bool IsVideo() const override { return false; }
5644

57-
static JSObject* ReadStructuredClone(JSContext* aCx, nsIGlobalObject* aGlobal,
58-
JSStructuredCloneReader* aReader,
59-
RTCEncodedAudioFrameData& aData);
60-
bool WriteStructuredClone(JSStructuredCloneWriter* aWriter,
61-
StructuredCloneHolder* aHolder) const;
62-
6345
private:
6446
virtual ~RTCEncodedAudioFrame();
65-
66-
// forbid copy/move to keep mState member in base valid
67-
RTCEncodedAudioFrame(const RTCEncodedAudioFrame&) = delete;
68-
RTCEncodedAudioFrame& operator=(const RTCEncodedAudioFrame&) = delete;
69-
RTCEncodedAudioFrame(RTCEncodedAudioFrame&&) = delete;
70-
RTCEncodedAudioFrame& operator=(RTCEncodedAudioFrame&&) = delete;
71-
72-
// RTCEncodedAudioFrame can run on either main thread or worker thread.
73-
void AssertIsOnOwningThread() const {
74-
NS_ASSERT_OWNINGTHREAD(RTCEncodedAudioFrame);
75-
}
76-
7747
RefPtr<RTCRtpScriptTransformer> mOwner;
48+
RTCEncodedAudioFrameMetadata mMetadata;
7849
};
7950

8051
} // namespace mozilla::dom

0 commit comments

Comments
 (0)