-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Target in FID and INP is null #335
Comments
Hi @markusBurda this is a known limitation with PerformanceEventTiming when the target element is removed from the DOM as part of the interaction, or for any other reason before the entry fires. For example if the interaction is a button click that dismisses a modal and so the button that was click is no longer in the DOM. You can see that document here in MDN: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEventTiming/target
There's more discussion of the issue here: w3c/event-timing#126 Would that explain your issue? You should still get FID/INP node details for those interactions where the node is not removed from the DOM. Barry P.S. I noticed you've a number of helper classes to obtain the the attribution information, but you're already pulling in the attribution build which provides APIs to give that information directly. Any reason you're not using the in-built ones? Details here: https://github.com/GoogleChrome/web-vitals#send-attribution-data |
Hi @tunetheweb, thanks for your quick answer. Actually I get the target: null in all the cases. Also when its just a simple a-tag click (with no js on it) or on a burger-icon (which stays in DOM after clicked). The example above is from a click on a burger menu. Do you know why I get a target in INP but no target on the FID entries? Its the same click-event. P.S.: The helper classes where necessary in previous versions. I'm very happy that they are not needed anymore. |
Interesting. This looks like a bug in Chrome. I've opened this to track: https://bugs.chromium.org/p/chromium/issues/detail?id=1428899 |
How about use I got a lot of If we use eg: If we get this xpath sting from CLS target prop, we can know its className, DOM tree path, and finally location which element it is. |
This issue is when an element is is disconnected from the DOM tree the Performance Observer entry returns However, there are a number of different issue here that are easy to confuse:
|
Hi @tunetheweb , We recently shifted to using the Even we are noticing that occassionally we are seeing a The web-page below is one where I'm able to reproduce the issue quite consistently for Attaching screenshots for reference:
The LCP element expected is one of the 3 images displayed in the Carousel at the top. The images in the above link are Is there anything I could do, to investigate further on why the LCP element is coming as |
When I block |
@tunetheweb thanks for quick reply. So, at the moment, if there is any re-mounting of a Node (delete and recreate) which happens to be the LCP element, then the |
Yes because effectively that is a new element and if the metric is reported on the previous element, then it's no longer in existence to reference. See the Spec discussion. Of course, if the remount results in a new metric (e.g. it's an ever so slightly larger LCP element) then it would issue a new LCP observation and so would have the node. |
Update on this issue:
We've released 3.5.2 which attempts to get the first non-null element for the INP event which should work around around the first issue. Will be interesting to see how much this improves the situation and how much the second issue is still a pain point. |
@tunetheweb I upgraded to version 3.5.2, but the result has not changed much. I see null data. |
As noted in #335 (comment) there were two main outstanding issues that we were aware of - both issues in Chromium rather than anything this library can necessarily resolve.
The change we made with 3.5.2 to workaround this was to look at other events in the same interaction. For example, and interaction might be made up of a pointer down, pointer up, and click events. If either of the pointer events are the longest events they may be reported as the “INP event” and its target given. As of 3.5.2, if that target is null, we will look at the other events in that interaction to try to find a non-null target. This is a workaround and though and in some cases there may not be a target even then. This particularly affects short events (where the FID event is reported as INP and it only has the first). We were unable to estimate how much this workaround would help but it was definitely known this would not solve all the issues. The good news is we’ve made significant progress on the underlying bug where and think these may be reported in a future version of Chrome (probably Chrome 123). This is the better fix rather than the workaround we tried in this library.
This is technically correct according to spec, but obviously painful for those trying to identify INP causes! We have further good news here, in that we think we have a way forward here too. Basically we will grab some details at the time of the interaction to use later even if the element doesn’t exist. This may not be the same selector that the web-vitals library would have used, but hopefully will be enough to identify the element (particularly if a unique id, or a class that makes it identifiable is present on the element!). Not sure when exactly this will land as still some details to be worked out but at earliest Chrome 123. so to your example, yes in theory it could happen to any element, but it’s more likely to happen to specific ones (ones that have pointer events, very low INP, or for elements which are then removed from the DOM as part of the interaction or shortly afterwards). Hopefully the workaround in 3.5.2 has helped a little (and certainly shouldn’t have made it any worse), but we need those two fixes implemented to really resolve this (and hopefully not end up revealing other issues we have not considered so far!). I’ll keep this issue open and update it as the situation changes. |
FWIW the first issue, the "null" target fix is in the latest Chrome Canary, and so the latest web-vitals.js could be tested against it. |
@mmocny does it mean that we still cannot get the element if the user is using an older version of Chrome or Chromium based browsers? (Like Samsung Internet) |
There are a few reasons why target could be null. The issues related to pointer events sometimes not having a target, do require Chrome m123 release. Separately web-vitals.js has made changes to report not just the target of the first event timing entry, but the first non-null target of any event timing entry. That change might help even older browser versions. |
Hi guys,
Im using your nice script to measuer web vitals on our website. To make optimization easier, we are also persisting the target-elemtent. It works fine with CLS and LCP but in FID and INP I get "null" for the target Element as you can see in this screenshot:
This is how I use it:
Do you know why? Am I doing something wrong?
The text was updated successfully, but these errors were encountered: