Bug 1690857 - Add diagnostic assert to ensure we aren't using stale blob keys in the compositor process. r=jrmuizel

Similar to bug 1690821 in the content process, this adds an assert in
the other side in case of a race condition.

Differential Revision: https://phabricator.services.mozilla.com/D104086
This commit is contained in:
Andrew Osmond 2021-02-04 19:05:50 +00:00
parent e8ebbd9d35
commit b4617507c5
2 changed files with 14 additions and 0 deletions

View File

@ -518,6 +518,8 @@ bool WebRenderBridgeParent::UpdateResources(
}
case OpUpdateResource::TOpAddBlobImage: {
const auto& op = cmd.get_OpAddBlobImage();
MOZ_DIAGNOSTIC_ASSERT(MatchesNamespace(op.key()),
"stale blob key for add!");
wr::Vec<uint8_t> bytes;
if (!reader.Read(op.bytes(), bytes)) {
gfxCriticalNote << "TOpAddBlobImage failed";
@ -529,6 +531,8 @@ bool WebRenderBridgeParent::UpdateResources(
}
case OpUpdateResource::TOpUpdateBlobImage: {
const auto& op = cmd.get_OpUpdateBlobImage();
MOZ_DIAGNOSTIC_ASSERT(MatchesNamespace(op.key()),
"stale blob key for update!");
wr::Vec<uint8_t> bytes;
if (!reader.Read(op.bytes(), bytes)) {
gfxCriticalNote << "TOpUpdateBlobImage failed";
@ -541,6 +545,8 @@ bool WebRenderBridgeParent::UpdateResources(
}
case OpUpdateResource::TOpSetBlobImageVisibleArea: {
const auto& op = cmd.get_OpSetBlobImageVisibleArea();
MOZ_DIAGNOSTIC_ASSERT(MatchesNamespace(op.key()),
"stale blob key for visible area!");
aUpdates.SetBlobImageVisibleArea(op.key(),
wr::ToDeviceIntRect(op.area()));
break;

View File

@ -220,6 +220,14 @@ class WebRenderBridgeParent final : public PWebRenderBridgeParent,
wr::Epoch GetCurrentEpoch() const { return mWrEpoch; }
wr::IdNamespace GetIdNamespace() { return mIdNamespace; }
bool MatchesNamespace(const wr::ImageKey& aImageKey) const {
return aImageKey.mNamespace == mIdNamespace;
}
bool MatchesNamespace(const wr::BlobImageKey& aBlobKey) const {
return MatchesNamespace(aBlobKey._0);
}
void FlushRendering(bool aWaitForPresent = true);
/**