2022-02-03

Tech Programing

程式人小天地

Why does hit test seem to be calling my code in chrome devtools perf tab

1 min read


I have a website I’m working on where there is an iframe which calls document.elementFromPoint in a loop in an event handler a bunch of times. I did a performance snapshot of the code and saw something strange.
It seems like hit test, which is a internal browser thing, is calling my anonymous event handler which is calling element from point. But this doesn’t make any sense. It should be that my event handler is calling elementFromPoint which then should be calling hit test, assuming hit test is what is internally used in elementFromPoint. Also I don’t see why there seem to be gaps in the main thread.
Can anyone explain why this is happening?

Other details.

  • The Iframe has same origin
  • document.elementFromPoint is getting svg elements

What I have found.

  • When the loop is not so long the order is correct, my code calls elementfrompoint calls hit test.
  • Long loops seem to cause the issue



Source link

資料來源:Stackoverflow

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *