Skip to content

Commit ea34810

Browse files
author
Razvan Maries
committed
Backed out 4 changesets (bug 1657404) for perma failures on GamepadPlatformService.cpp. CLOSED TREE
Backed out changeset a79143c550d7 (bug 1657404) Backed out changeset ae904c76b6cc (bug 1657404) Backed out changeset b225f6a01afe (bug 1657404) Backed out changeset e6e1924fb688 (bug 1657404)
1 parent 824fb76 commit ea34810

11 files changed

+78
-52
lines changed

dom/gamepad/GamepadServiceTest.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,16 @@ void GamepadServiceTest::InitPBackgroundActor() {
7171
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
7272
}
7373

74-
mChild = GamepadTestChannelChild::Create();
74+
mChild = new GamepadTestChannelChild();
7575
PGamepadTestChannelChild* initedChild =
76-
actor->SendPGamepadTestChannelConstructor(mChild.get());
76+
actor->SendPGamepadTestChannelConstructor(mChild);
7777
if (NS_WARN_IF(!initedChild)) {
7878
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
7979
}
8080
}
8181

8282
void GamepadServiceTest::DestroyPBackgroundActor() {
83-
MOZ_ASSERT(mChild);
84-
PGamepadTestChannelChild::Send__delete__(mChild);
83+
mChild->SendShutdownChannel();
8584
mChild = nullptr;
8685
}
8786

dom/gamepad/GamepadServiceTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class GamepadServiceTest final : public DOMEventTargetHelper {
7070
// IPDL Channel for us to send test events to GamepadPlatformService, it
7171
// will only be used in this singleton class and deleted during the IPDL
7272
// shutdown chain
73-
RefPtr<GamepadTestChannelChild> mChild;
73+
GamepadTestChannelChild* MOZ_NON_OWNING_REF mChild;
7474

7575
explicit GamepadServiceTest(nsPIDOMWindowInner* aWindow);
7676
~GamepadServiceTest();

dom/gamepad/ipc/GamepadTestChannelChild.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
namespace mozilla {
1010
namespace dom {
1111

12-
already_AddRefed<GamepadTestChannelChild> GamepadTestChannelChild::Create() {
13-
return RefPtr<GamepadTestChannelChild>(new GamepadTestChannelChild())
14-
.forget();
15-
}
16-
1712
void GamepadTestChannelChild::AddPromise(const uint32_t& aID,
1813
Promise* aPromise) {
1914
MOZ_ASSERT(!mPromiseList.Get(aID, nullptr));

dom/gamepad/ipc/GamepadTestChannelChild.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,18 @@ namespace mozilla {
1414
namespace dom {
1515

1616
class GamepadTestChannelChild final : public PGamepadTestChannelChild {
17-
public:
18-
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadTestChannelChild)
19-
20-
static already_AddRefed<GamepadTestChannelChild> Create();
21-
22-
void AddPromise(const uint32_t& aID, Promise* aPromise);
23-
24-
GamepadTestChannelChild(const GamepadTestChannelChild&) = delete;
25-
GamepadTestChannelChild(GamepadTestChannelChild&&) = delete;
26-
GamepadTestChannelChild& operator=(const GamepadTestChannelChild&) = delete;
27-
GamepadTestChannelChild& operator=(GamepadTestChannelChild&&) = delete;
17+
friend class PGamepadTestChannelChild;
2818

29-
private:
19+
public:
3020
GamepadTestChannelChild() = default;
3121
~GamepadTestChannelChild() = default;
22+
void AddPromise(const uint32_t& aID, Promise* aPromise);
3223

24+
private:
3325
mozilla::ipc::IPCResult RecvReplyGamepadIndex(const uint32_t& aID,
3426
const uint32_t& aIndex);
3527

3628
nsRefPtrHashtable<nsUint32HashKey, dom::Promise> mPromiseList;
37-
38-
friend class PGamepadTestChannelChild;
3929
};
4030

4131
} // namespace dom

dom/gamepad/ipc/GamepadTestChannelParent.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,18 @@
1212
namespace mozilla {
1313
namespace dom {
1414

15-
already_AddRefed<GamepadTestChannelParent> GamepadTestChannelParent::Create() {
16-
return RefPtr<GamepadTestChannelParent>(new GamepadTestChannelParent())
17-
.forget();
18-
}
19-
20-
GamepadTestChannelParent::GamepadTestChannelParent() {
15+
bool GamepadTestChannelParent::Init() {
2116
AssertIsOnBackgroundThread();
2217
RefPtr<GamepadPlatformService> service =
2318
GamepadPlatformService::GetParentService();
2419
MOZ_ASSERT(service);
2520

2621
service->GetMonitoringState().AddObserver(this);
22+
23+
return true;
2724
}
2825

29-
GamepadTestChannelParent::~GamepadTestChannelParent() {
26+
void GamepadTestChannelParent::ActorDestroy(ActorDestroyReason aWhy) {
3027
AssertIsOnBackgroundThread();
3128
RefPtr<GamepadPlatformService> service =
3229
GamepadPlatformService::GetParentService();
@@ -50,8 +47,9 @@ void GamepadTestChannelParent::AddGamepadToPlatformService(
5047
gamepadID.get(), static_cast<GamepadMappingType>(a.mapping()), a.hand(),
5148
a.num_buttons(), a.num_axes(), a.num_haptics(), a.num_lights(),
5249
a.num_touches());
53-
54-
Unused << SendReplyGamepadIndex(aPromiseId, index);
50+
if (!mShuttingdown) {
51+
Unused << SendReplyGamepadIndex(aPromiseId, index);
52+
}
5553
}
5654

5755
void GamepadTestChannelParent::OnMonitoringStateChanged(bool aNewState) {
@@ -125,5 +123,11 @@ mozilla::ipc::IPCResult GamepadTestChannelParent::RecvGamepadTestEvent(
125123
return IPC_FAIL_NO_REASON(this);
126124
}
127125

126+
mozilla::ipc::IPCResult GamepadTestChannelParent::RecvShutdownChannel() {
127+
mShuttingdown = true;
128+
Unused << Send__delete__(this);
129+
return IPC_OK();
130+
}
131+
128132
} // namespace dom
129133
} // namespace mozilla

dom/gamepad/ipc/GamepadTestChannelParent.h

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,24 @@ class GamepadTestChannelParent final : public PGamepadTestChannelParent,
1717
public SupportsWeakPtr {
1818
public:
1919
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadTestChannelParent)
20-
21-
static already_AddRefed<GamepadTestChannelParent> Create();
22-
20+
GamepadTestChannelParent() : mShuttingdown(false) {}
21+
bool Init();
22+
void ActorDestroy(ActorDestroyReason aWhy) override;
2323
mozilla::ipc::IPCResult RecvGamepadTestEvent(
2424
const uint32_t& aID, const GamepadChangeEvent& aGamepadEvent);
25+
mozilla::ipc::IPCResult RecvShutdownChannel();
2526

2627
void OnMonitoringStateChanged(bool aNewState);
2728

28-
GamepadTestChannelParent(const GamepadTestChannelParent&) = delete;
29-
GamepadTestChannelParent(GamepadTestChannelParent&&) = delete;
30-
GamepadTestChannelParent& operator=(const GamepadTestChannelParent&) = delete;
31-
GamepadTestChannelParent& operator=(GamepadTestChannelParent&&) = delete;
32-
3329
private:
3430
struct DeferredGamepadAdded {
3531
uint32_t promiseId;
3632
GamepadAdded gamepadAdded;
3733
};
38-
39-
GamepadTestChannelParent();
40-
~GamepadTestChannelParent();
41-
4234
void AddGamepadToPlatformService(uint32_t aPromiseId,
4335
const GamepadAdded& aGamepadAdded);
44-
36+
~GamepadTestChannelParent() = default;
37+
bool mShuttingdown;
4538
nsTArray<DeferredGamepadAdded> mDeferredGamepadAdded;
4639
};
4740

dom/gamepad/ipc/PGamepadTestChannel.ipdl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ include GamepadEventTypes;
77
namespace mozilla {
88
namespace dom {
99

10-
refcounted protocol PGamepadTestChannel {
10+
async protocol PGamepadTestChannel {
1111
manager PBackground;
1212
parent:
1313
async GamepadTestEvent(uint32_t aID, GamepadChangeEvent aGamepadEvent);
14-
async __delete__();
14+
async ShutdownChannel();
1515
child:
16+
async __delete__();
1617
async ReplyGamepadIndex(uint32_t aID, uint32_t aIndex);
1718
};
1819

ipc/glue/BackgroundChildImpl.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,19 @@ bool BackgroundChildImpl::DeallocPGamepadEventChannelChild(
619619
return true;
620620
}
621621

622+
dom::PGamepadTestChannelChild*
623+
BackgroundChildImpl::AllocPGamepadTestChannelChild() {
624+
MOZ_CRASH("PGamepadTestChannelChild actor should be manually constructed!");
625+
return nullptr;
626+
}
627+
628+
bool BackgroundChildImpl::DeallocPGamepadTestChannelChild(
629+
PGamepadTestChannelChild* aActor) {
630+
MOZ_ASSERT(aActor);
631+
delete static_cast<dom::GamepadTestChannelChild*>(aActor);
632+
return true;
633+
}
634+
622635
mozilla::dom::PClientManagerChild*
623636
BackgroundChildImpl::AllocPClientManagerChild() {
624637
return mozilla::dom::AllocClientManagerChild();

ipc/glue/BackgroundChildImpl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ class BackgroundChildImpl : public PBackgroundChild,
229229
virtual bool DeallocPGamepadEventChannelChild(
230230
PGamepadEventChannelChild* aActor) override;
231231

232+
virtual PGamepadTestChannelChild* AllocPGamepadTestChannelChild() override;
233+
234+
virtual bool DeallocPGamepadTestChannelChild(
235+
PGamepadTestChannelChild* aActor) override;
236+
232237
virtual PClientManagerChild* AllocPClientManagerChild() override;
233238

234239
virtual bool DeallocPClientManagerChild(PClientManagerChild* aActor) override;

ipc/glue/BackgroundParentImpl.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,30 @@ BackgroundParentImpl::RecvPGamepadEventChannelConstructor(
11201120
return IPC_OK();
11211121
}
11221122

1123-
already_AddRefed<dom::PGamepadTestChannelParent>
1123+
dom::PGamepadTestChannelParent*
11241124
BackgroundParentImpl::AllocPGamepadTestChannelParent() {
1125-
return dom::GamepadTestChannelParent::Create();
1125+
RefPtr<dom::GamepadTestChannelParent> parent =
1126+
new dom::GamepadTestChannelParent();
1127+
1128+
return parent.forget().take();
1129+
}
1130+
1131+
mozilla::ipc::IPCResult
1132+
BackgroundParentImpl::RecvPGamepadTestChannelConstructor(
1133+
PGamepadTestChannelParent* aActor) {
1134+
MOZ_ASSERT(aActor);
1135+
if (!static_cast<dom::GamepadTestChannelParent*>(aActor)->Init()) {
1136+
return IPC_FAIL_NO_REASON(this);
1137+
}
1138+
return IPC_OK();
1139+
}
1140+
1141+
bool BackgroundParentImpl::DeallocPGamepadTestChannelParent(
1142+
dom::PGamepadTestChannelParent* aActor) {
1143+
MOZ_ASSERT(aActor);
1144+
RefPtr<dom::GamepadTestChannelParent> parent =
1145+
dont_AddRef(static_cast<dom::GamepadTestChannelParent*>(aActor));
1146+
return true;
11261147
}
11271148

11281149
dom::PWebAuthnTransactionParent*

ipc/glue/BackgroundParentImpl.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,13 @@ class BackgroundParentImpl : public PBackgroundParent,
332332
virtual mozilla::ipc::IPCResult RecvPGamepadEventChannelConstructor(
333333
PGamepadEventChannelParent* aActor) override;
334334

335-
virtual already_AddRefed<PGamepadTestChannelParent>
336-
AllocPGamepadTestChannelParent() override;
335+
virtual PGamepadTestChannelParent* AllocPGamepadTestChannelParent() override;
336+
337+
virtual mozilla::ipc::IPCResult RecvPGamepadTestChannelConstructor(
338+
PGamepadTestChannelParent* aActor) override;
339+
340+
virtual bool DeallocPGamepadTestChannelParent(
341+
PGamepadTestChannelParent* aActor) override;
337342

338343
virtual PWebAuthnTransactionParent* AllocPWebAuthnTransactionParent()
339344
override;

0 commit comments

Comments
 (0)