@@ -498,6 +498,11 @@ bool WebRenderBridgeParent::UpdateResources(
498
498
switch (cmd.type ()) {
499
499
case OpUpdateResource::TOpAddImage: {
500
500
const auto & op = cmd.get_OpAddImage ();
501
+ if (!MatchesNamespace (op.key ())) {
502
+ MOZ_ASSERT_UNREACHABLE (" Stale image key (add)!" );
503
+ break ;
504
+ }
505
+
501
506
wr::Vec<uint8_t > bytes;
502
507
if (!reader.Read (op.bytes (), bytes)) {
503
508
return false ;
@@ -507,6 +512,11 @@ bool WebRenderBridgeParent::UpdateResources(
507
512
}
508
513
case OpUpdateResource::TOpUpdateImage: {
509
514
const auto & op = cmd.get_OpUpdateImage ();
515
+ if (!MatchesNamespace (op.key ())) {
516
+ MOZ_ASSERT_UNREACHABLE (" Stale image key (update)!" );
517
+ break ;
518
+ }
519
+
510
520
wr::Vec<uint8_t > bytes;
511
521
if (!reader.Read (op.bytes (), bytes)) {
512
522
return false ;
@@ -516,6 +526,11 @@ bool WebRenderBridgeParent::UpdateResources(
516
526
}
517
527
case OpUpdateResource::TOpAddBlobImage: {
518
528
const auto & op = cmd.get_OpAddBlobImage ();
529
+ if (!MatchesNamespace (op.key ())) {
530
+ MOZ_ASSERT_UNREACHABLE (" Stale blob image key (add)!" );
531
+ break ;
532
+ }
533
+
519
534
wr::Vec<uint8_t > bytes;
520
535
if (!reader.Read (op.bytes (), bytes)) {
521
536
return false ;
@@ -526,6 +541,11 @@ bool WebRenderBridgeParent::UpdateResources(
526
541
}
527
542
case OpUpdateResource::TOpUpdateBlobImage: {
528
543
const auto & op = cmd.get_OpUpdateBlobImage ();
544
+ if (!MatchesNamespace (op.key ())) {
545
+ MOZ_ASSERT_UNREACHABLE (" Stale blob image key (update)!" );
546
+ break ;
547
+ }
548
+
529
549
wr::Vec<uint8_t > bytes;
530
550
if (!reader.Read (op.bytes (), bytes)) {
531
551
return false ;
@@ -537,6 +557,10 @@ bool WebRenderBridgeParent::UpdateResources(
537
557
}
538
558
case OpUpdateResource::TOpSetBlobImageVisibleArea: {
539
559
const auto & op = cmd.get_OpSetBlobImageVisibleArea ();
560
+ if (!MatchesNamespace (op.key ())) {
561
+ MOZ_ASSERT_UNREACHABLE (" Stale blob image key (visible)!" );
562
+ break ;
563
+ }
540
564
aUpdates.SetBlobImageVisibleArea (op.key (),
541
565
wr::ToDeviceIntRect (op.area ()));
542
566
break ;
@@ -592,6 +616,11 @@ bool WebRenderBridgeParent::UpdateResources(
592
616
}
593
617
case OpUpdateResource::TOpAddFontDescriptor: {
594
618
const auto & op = cmd.get_OpAddFontDescriptor ();
619
+ if (!MatchesNamespace (op.key ())) {
620
+ MOZ_ASSERT_UNREACHABLE (" Stale font key (add descriptor)!" );
621
+ break ;
622
+ }
623
+
595
624
wr::Vec<uint8_t > bytes;
596
625
if (!reader.Read (op.bytes (), bytes)) {
597
626
return false ;
@@ -601,6 +630,12 @@ bool WebRenderBridgeParent::UpdateResources(
601
630
}
602
631
case OpUpdateResource::TOpAddFontInstance: {
603
632
const auto & op = cmd.get_OpAddFontInstance ();
633
+ if (!MatchesNamespace (op.instanceKey ()) ||
634
+ !MatchesNamespace (op.fontKey ())) {
635
+ MOZ_ASSERT_UNREACHABLE (" Stale font key (add instance)!" );
636
+ break ;
637
+ }
638
+
604
639
wr::Vec<uint8_t > variations;
605
640
if (!reader.Read (op.variations (), variations)) {
606
641
return false ;
@@ -613,21 +648,43 @@ bool WebRenderBridgeParent::UpdateResources(
613
648
}
614
649
case OpUpdateResource::TOpDeleteImage: {
615
650
const auto & op = cmd.get_OpDeleteImage ();
651
+ if (!MatchesNamespace (op.key ())) {
652
+ // TODO(aosmond): We should also assert here, but the callers are less
653
+ // careful about checking when cleaning up their old keys. We should
654
+ // perform an audit on image key usage.
655
+ break ;
656
+ }
657
+
616
658
DeleteImage (op.key (), aUpdates);
617
659
break ;
618
660
}
619
661
case OpUpdateResource::TOpDeleteBlobImage: {
620
662
const auto & op = cmd.get_OpDeleteBlobImage ();
663
+ if (!MatchesNamespace (op.key ())) {
664
+ MOZ_ASSERT_UNREACHABLE (" Stale blob image key (delete)!" );
665
+ break ;
666
+ }
667
+
621
668
aUpdates.DeleteBlobImage (op.key ());
622
669
break ;
623
670
}
624
671
case OpUpdateResource::TOpDeleteFont: {
625
672
const auto & op = cmd.get_OpDeleteFont ();
673
+ if (!MatchesNamespace (op.key ())) {
674
+ MOZ_ASSERT_UNREACHABLE (" Stale font key (delete)!" );
675
+ break ;
676
+ }
677
+
626
678
aUpdates.DeleteFont (op.key ());
627
679
break ;
628
680
}
629
681
case OpUpdateResource::TOpDeleteFontInstance: {
630
682
const auto & op = cmd.get_OpDeleteFontInstance ();
683
+ if (!MatchesNamespace (op.key ())) {
684
+ MOZ_ASSERT_UNREACHABLE (" Stale font instance key (delete)!" );
685
+ break ;
686
+ }
687
+
631
688
aUpdates.DeleteFontInstance (op.key ());
632
689
break ;
633
690
}
@@ -650,9 +707,8 @@ bool WebRenderBridgeParent::UpdateResources(
650
707
bool WebRenderBridgeParent::AddPrivateExternalImage (
651
708
wr::ExternalImageId aExtId, wr::ImageKey aKey, wr::ImageDescriptor aDesc,
652
709
wr::TransactionBuilder& aResources) {
653
- Range<wr::ImageKey> keys (&aKey, 1 );
654
- // Check if key is obsoleted.
655
- if (keys[0 ].mNamespace != mIdNamespace ) {
710
+ if (!MatchesNamespace (aKey)) {
711
+ MOZ_ASSERT_UNREACHABLE (" Stale private external image key (add)!" );
656
712
return true ;
657
713
}
658
714
@@ -666,9 +722,8 @@ bool WebRenderBridgeParent::UpdatePrivateExternalImage(
666
722
wr::ExternalImageId aExtId, wr::ImageKey aKey,
667
723
const wr::ImageDescriptor& aDesc, const ImageIntRect& aDirtyRect,
668
724
wr::TransactionBuilder& aResources) {
669
- Range<wr::ImageKey> keys (&aKey, 1 );
670
- // Check if key is obsoleted.
671
- if (keys[0 ].mNamespace != mIdNamespace ) {
725
+ if (!MatchesNamespace (aKey)) {
726
+ MOZ_ASSERT_UNREACHABLE (" Stale private external image key (update)!" );
672
727
return true ;
673
728
}
674
729
@@ -682,9 +737,8 @@ bool WebRenderBridgeParent::UpdatePrivateExternalImage(
682
737
bool WebRenderBridgeParent::AddSharedExternalImage (
683
738
wr::ExternalImageId aExtId, wr::ImageKey aKey,
684
739
wr::TransactionBuilder& aResources) {
685
- Range<wr::ImageKey> keys (&aKey, 1 );
686
- // Check if key is obsoleted.
687
- if (keys[0 ].mNamespace != mIdNamespace ) {
740
+ if (!MatchesNamespace (aKey)) {
741
+ MOZ_ASSERT_UNREACHABLE (" Stale shared external image key (add)!" );
688
742
return true ;
689
743
}
690
744
@@ -718,10 +772,8 @@ bool WebRenderBridgeParent::AddSharedExternalImage(
718
772
bool WebRenderBridgeParent::PushExternalImageForTexture (
719
773
wr::ExternalImageId aExtId, wr::ImageKey aKey, TextureHost* aTexture,
720
774
bool aIsUpdate, wr::TransactionBuilder& aResources) {
721
- auto op = aIsUpdate ? TextureHost::UPDATE_IMAGE : TextureHost::ADD_IMAGE;
722
- Range<wr::ImageKey> keys (&aKey, 1 );
723
- // Check if key is obsoleted.
724
- if (keys[0 ].mNamespace != mIdNamespace ) {
775
+ if (!MatchesNamespace (aKey)) {
776
+ MOZ_ASSERT_UNREACHABLE (" Stale texture external image key!" );
725
777
return true ;
726
778
}
727
779
@@ -731,8 +783,10 @@ bool WebRenderBridgeParent::PushExternalImageForTexture(
731
783
return false ;
732
784
}
733
785
786
+ auto op = aIsUpdate ? TextureHost::UPDATE_IMAGE : TextureHost::ADD_IMAGE;
734
787
WebRenderTextureHost* wrTexture = aTexture->AsWebRenderTextureHost ();
735
788
if (wrTexture) {
789
+ Range<wr::ImageKey> keys (&aKey, 1 );
736
790
wrTexture->PushResourceUpdates (aResources, op, keys,
737
791
wrTexture->GetExternalImageKey ());
738
792
auto it = mTextureHosts .find (wr::AsUint64 (aKey));
@@ -768,9 +822,9 @@ bool WebRenderBridgeParent::PushExternalImageForTexture(
768
822
data.PushBytes (Range<uint8_t >(map.mData , size.height * map.mStride ));
769
823
770
824
if (op == TextureHost::UPDATE_IMAGE) {
771
- aResources.UpdateImageBuffer (keys[ 0 ] , descriptor, data);
825
+ aResources.UpdateImageBuffer (aKey , descriptor, data);
772
826
} else {
773
- aResources.AddImage (keys[ 0 ] , descriptor, data);
827
+ aResources.AddImage (aKey , descriptor, data);
774
828
}
775
829
776
830
dSurf->Unmap ();
@@ -782,9 +836,8 @@ bool WebRenderBridgeParent::UpdateSharedExternalImage(
782
836
wr::ExternalImageId aExtId, wr::ImageKey aKey,
783
837
const ImageIntRect& aDirtyRect, wr::TransactionBuilder& aResources,
784
838
UniquePtr<ScheduleSharedSurfaceRelease>& aScheduleRelease) {
785
- Range<wr::ImageKey> keys (&aKey, 1 );
786
- // Check if key is obsoleted.
787
- if (keys[0 ].mNamespace != mIdNamespace ) {
839
+ if (!MatchesNamespace (aKey)) {
840
+ MOZ_ASSERT_UNREACHABLE (" Stale shared external image key (update)!" );
788
841
return true ;
789
842
}
790
843
@@ -842,10 +895,11 @@ void WebRenderBridgeParent::ObserveSharedSurfaceRelease(
842
895
}
843
896
844
897
mozilla::ipc::IPCResult WebRenderBridgeParent::RecvUpdateResources (
898
+ const wr::IdNamespace& aIdNamespace,
845
899
nsTArray<OpUpdateResource>&& aResourceUpdates,
846
900
nsTArray<RefCountedShmem>&& aSmallShmems,
847
901
nsTArray<ipc::Shmem>&& aLargeShmems) {
848
- if (mDestroyed ) {
902
+ if (mDestroyed || aIdNamespace != mIdNamespace ) {
849
903
wr::IpcResourceUpdateQueue::ReleaseShmems (this , aSmallShmems);
850
904
wr::IpcResourceUpdateQueue::ReleaseShmems (this , aLargeShmems);
851
905
return IPC_OK ();
@@ -1043,7 +1097,7 @@ bool WebRenderBridgeParent::SetDisplayList(
1043
1097
const nsTArray<OpUpdateResource>& aResourceUpdates,
1044
1098
const nsTArray<RefCountedShmem>& aSmallShmems,
1045
1099
const nsTArray<ipc::Shmem>& aLargeShmems, const TimeStamp& aTxnStartTime,
1046
- wr::TransactionBuilder& aTxn, wr::Epoch aWrEpoch, bool aValidTransaction,
1100
+ wr::TransactionBuilder& aTxn, wr::Epoch aWrEpoch,
1047
1101
bool aObserveLayersUpdate) {
1048
1102
if (NS_WARN_IF(!UpdateResources (aResourceUpdates, aSmallShmems, aLargeShmems,
1049
1103
aTxn))) {
@@ -1052,37 +1106,33 @@ bool WebRenderBridgeParent::SetDisplayList(
1052
1106
1053
1107
wr::Vec<uint8_t > dlData (std::move (aDL));
1054
1108
1055
- if (aValidTransaction) {
1056
- if (IsRootWebRenderBridgeParent ()) {
1057
- LayoutDeviceIntSize widgetSize = mWidget ->GetClientSize ();
1058
- LayoutDeviceIntRect rect =
1059
- LayoutDeviceIntRect (LayoutDeviceIntPoint (), widgetSize);
1060
- aTxn.SetDocumentView (rect);
1061
- }
1062
- gfx::DeviceColor clearColor (0 .f , 0 .f , 0 .f , 0 .f );
1063
- aTxn.SetDisplayList (clearColor, aWrEpoch,
1064
- wr::ToLayoutSize (RoundedToInt (aRect).Size ()),
1065
- mPipelineId , aDLDesc, dlData);
1066
-
1067
- if (aObserveLayersUpdate) {
1068
- aTxn.Notify (wr::Checkpoint::SceneBuilt,
1069
- MakeUnique<ScheduleObserveLayersUpdate>(
1070
- mCompositorBridge , GetLayersId (),
1071
- mChildLayersObserverEpoch , true ));
1072
- }
1073
-
1074
- if (!IsRootWebRenderBridgeParent ()) {
1075
- aTxn.Notify (
1076
- wr::Checkpoint::SceneBuilt,
1077
- MakeUnique<SceneBuiltNotification>(this , aWrEpoch, aTxnStartTime));
1078
- }
1079
-
1080
- mApi ->SendTransaction (aTxn);
1109
+ if (IsRootWebRenderBridgeParent ()) {
1110
+ LayoutDeviceIntSize widgetSize = mWidget ->GetClientSize ();
1111
+ LayoutDeviceIntRect rect =
1112
+ LayoutDeviceIntRect (LayoutDeviceIntPoint (), widgetSize);
1113
+ aTxn.SetDocumentView (rect);
1114
+ }
1115
+ gfx::DeviceColor clearColor (0 .f , 0 .f , 0 .f , 0 .f );
1116
+ aTxn.SetDisplayList (clearColor, aWrEpoch,
1117
+ wr::ToLayoutSize (RoundedToInt (aRect).Size ()), mPipelineId ,
1118
+ aDLDesc, dlData);
1119
+
1120
+ if (aObserveLayersUpdate) {
1121
+ aTxn.Notify (
1122
+ wr::Checkpoint::SceneBuilt,
1123
+ MakeUnique<ScheduleObserveLayersUpdate>(
1124
+ mCompositorBridge , GetLayersId (), mChildLayersObserverEpoch , true ));
1125
+ }
1081
1126
1082
- // We will schedule generating a frame after the scene
1083
- // build is done, so we don't need to do it here.
1127
+ if (!IsRootWebRenderBridgeParent ()) {
1128
+ aTxn.Notify (wr::Checkpoint::SceneBuilt, MakeUnique<SceneBuiltNotification>(
1129
+ this , aWrEpoch, aTxnStartTime));
1084
1130
}
1085
1131
1132
+ mApi ->SendTransaction (aTxn);
1133
+
1134
+ // We will schedule generating a frame after the scene
1135
+ // build is done, so we don't need to do it here.
1086
1136
return true ;
1087
1137
}
1088
1138
@@ -1111,12 +1161,11 @@ bool WebRenderBridgeParent::ProcessDisplayListData(
1111
1161
return false ;
1112
1162
}
1113
1163
1114
- if (aDisplayList.mDL &&
1164
+ if (aDisplayList.mDL && aValidTransaction &&
1115
1165
!SetDisplayList (aDisplayList.mRect , std::move (aDisplayList.mDL .ref ()),
1116
1166
aDisplayList.mDLDesc , aDisplayList.mResourceUpdates ,
1117
1167
aDisplayList.mSmallShmems , aDisplayList.mLargeShmems ,
1118
- aTxnStartTime, txn, aWrEpoch, aValidTransaction,
1119
- aObserveLayersUpdate)) {
1168
+ aTxnStartTime, txn, aWrEpoch, aObserveLayersUpdate)) {
1120
1169
return false ;
1121
1170
}
1122
1171
return true ;
@@ -1161,6 +1210,8 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvSetDisplayList(
1161
1210
1162
1211
if (!ProcessDisplayListData (aDisplayList, wrEpoch, aTxnStartTime,
1163
1212
validTransaction, observeLayersUpdate)) {
1213
+ wr::IpcResourceUpdateQueue::ReleaseShmems (this , aDisplayList.mSmallShmems );
1214
+ wr::IpcResourceUpdateQueue::ReleaseShmems (this , aDisplayList.mLargeShmems );
1164
1215
return IPC_FAIL (this , " Failed to process DisplayListData." );
1165
1216
}
1166
1217
@@ -1212,7 +1263,8 @@ bool WebRenderBridgeParent::ProcessEmptyTransactionUpdates(
1212
1263
// AsyncImagePipelineManager.
1213
1264
Unused << GetNextWrEpoch ();
1214
1265
1215
- if (!UpdateResources (aData.mResourceUpdates , aData.mSmallShmems ,
1266
+ if (aData.mIdNamespace == mIdNamespace &&
1267
+ !UpdateResources (aData.mResourceUpdates , aData.mSmallShmems ,
1216
1268
aData.mLargeShmems , txn)) {
1217
1269
return false ;
1218
1270
}
@@ -1290,6 +1342,10 @@ mozilla::ipc::IPCResult WebRenderBridgeParent::RecvEmptyTransaction(
1290
1342
bool scheduleComposite = false ;
1291
1343
if (!ProcessEmptyTransactionUpdates (*aTransactionData,
1292
1344
&scheduleComposite)) {
1345
+ wr::IpcResourceUpdateQueue::ReleaseShmems (this ,
1346
+ aTransactionData->mSmallShmems );
1347
+ wr::IpcResourceUpdateQueue::ReleaseShmems (this ,
1348
+ aTransactionData->mLargeShmems );
1293
1349
return IPC_FAIL (this , " Failed to process empty transaction update." );
1294
1350
}
1295
1351
scheduleAnyComposite = scheduleAnyComposite || scheduleComposite;
0 commit comments