Bug 1749109 - Relax assert in webrender hit testing. r=botond

Relax the asserts found related to a hit-test result finding an associated
target APZC. When the layers id is not found in the layer tree map. There are
reasonable cases when this could exist. For example, this may happen when the
target layer tree has already been destroyed.

Differential Revision: https://phabricator.services.mozilla.com/D212732
This commit is contained in:
Dan Robertson 2024-06-21 15:22:14 +00:00
Родитель 5f34693f8d
Коммит bd09359a37
3 изменённых файлов: 42 добавлений и 7 удалений

Просмотреть файл

@ -9,6 +9,7 @@
#include "APZCTreeManager.h"
#include "TreeTraversal.h" // for BreadthFirstSearch
#include "mozilla/gfx/CompositorHitTestInfo.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/webrender/WebRenderAPI.h"
#include "nsDebug.h" // for NS_ASSERTION
#include "nsIXULRuntime.h" // for FissionAutostart
@ -91,6 +92,12 @@ IAPZHitTester::HitTestResult WRHitTester::GetAPZCAtPoint(
wr->HitTest(wr::ToWorldPoint(aHitTestPoint));
Maybe<wr::WrHitResult> chosenResult;
// It's possible for the WebRender hit test to produce a result with
// a LayersId whose corresponding layer tree has already been
// torn down (e.g. during window/tab shutdown, or navigation to
// a different domain). This is expected, so avoid debug assertions
// firing in this scenario.
DebugOnly<bool> layersIdExists = true;
for (const wr::WrHitResult& result : results) {
ScrollableLayerGuid guid{result.mLayersId, 0, result.mScrollId};
APZCTM_LOG("Examining result with guid %s hit info 0x%x... ",
@ -119,8 +126,11 @@ IAPZHitTester::HitTestResult WRHitTester::GetAPZCAtPoint(
// a known issue related to inactive scroll frames that can cause this
// to fire (see bug 1634763), which is fixed in Fission mode and not
// worth fixing in non-Fission mode.
layersIdExists =
CompositorBridgeParent::HasIndirectShadowTree(result.mLayersId);
if (FissionAutostart()) {
MOZ_ASSERT(result.mScrollId == ScrollableLayerGuid::NULL_SCROLL_ID);
MOZ_ASSERT(result.mScrollId == ScrollableLayerGuid::NULL_SCROLL_ID ||
!layersIdExists);
} else {
NS_ASSERTION(
result.mScrollId == ScrollableLayerGuid::NULL_SCROLL_ID,
@ -131,7 +141,8 @@ IAPZHitTester::HitTestResult WRHitTester::GetAPZCAtPoint(
if (!node) {
// Should never happen, but handle gracefully in release builds just
// in case.
MOZ_ASSERT(false);
MOZ_ASSERT(!layersIdExists,
"No root node found for hit-test result layers id");
chosenResult = Some(result);
break;
}
@ -163,7 +174,9 @@ IAPZHitTester::HitTestResult WRHitTester::GetAPZCAtPoint(
return hit;
}
MOZ_ASSERT(hit.mTargetApzc);
MOZ_ASSERT(
hit.mTargetApzc || !layersIdExists,
"A hit-test result with a valid layers id should have a target APZC");
hit.mLayersId = chosenResult->mLayersId;
ScrollableLayerGuid::ViewID scrollId = chosenResult->mScrollId;
gfx::CompositorHitTestInfo hitInfo = chosenResult->mHitInfo;

Просмотреть файл

@ -1596,10 +1596,7 @@ CompositorBridgeParent::GetAsyncImagePipelineManager() const {
}
/* static */ CompositorBridgeParent::LayerTreeState*
CompositorBridgeParent::GetIndirectShadowTree(LayersId aId) {
// Only the compositor thread should use this method variant
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
CompositorBridgeParent::GetIndirectShadowTreeInternal(LayersId aId) {
StaticMonitorAutoLock lock(sIndirectLayerTreesLock);
LayerTreeMap::iterator cit = sIndirectLayerTrees.find(aId);
if (sIndirectLayerTrees.end() == cit) {
@ -1608,6 +1605,19 @@ CompositorBridgeParent::GetIndirectShadowTree(LayersId aId) {
return &cit->second;
}
/* static */
bool CompositorBridgeParent::HasIndirectShadowTree(LayersId aId) {
return GetIndirectShadowTreeInternal(aId) != nullptr;
}
/* static */ CompositorBridgeParent::LayerTreeState*
CompositorBridgeParent::GetIndirectShadowTree(LayersId aId) {
// Only the compositor thread should use this method variant
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
return GetIndirectShadowTreeInternal(aId);
}
/* static */
bool CompositorBridgeParent::CallWithIndirectShadowTree(
LayersId aId,

Просмотреть файл

@ -417,6 +417,12 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
*/
static LayerTreeState* GetIndirectShadowTree(LayersId aId);
/**
* If a shadow tree exists for the given id |aId|, return true. Otherwise
* return false.
*/
static bool HasIndirectShadowTree(LayersId aId);
/**
* Lookup the indirect shadow tree for |aId|, call the function object and
* return true if found. If not found, return false.
@ -510,6 +516,12 @@ class CompositorBridgeParent final : public CompositorBridgeParentBase,
void FlushPendingWrTransactionEventsWithWait();
private:
/**
* Lookup the indirect shadow tree for |aId| and return it if it
* exists. Otherwise null is returned.
*/
static LayerTreeState* GetIndirectShadowTreeInternal(LayersId aId);
void Initialize();
/**