davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.
https://iframe-resizer.com
Other
6.66k stars 980 forks source link

ResizeObserver loop completed with undelivered notifications #1339

Open KoanLeeroy opened 2 days ago

KoanLeeroy commented 2 days ago

Describe the bug Just implemented 5.3.1 of the library. We are seeing daily unhandled exceptions thrown by Safari with the message: 'ResizeObserver loop completed with undelivered notifications'.

We do not see the issue ourselves, despite using the same browser, on the same site(s) that are logging this issue, so cannot reproduce, can Sentry is capturing the issue.

Screenshots image image

Desktop (please complete the following information):

davidjbradshaw commented 2 days ago

This seems to be a bug in Safari, that does not actually impact how iframe-resizer works. It's basically objecting to the fact the code runs so fast, that it has resized the iframe on the parent page within the same animation frame that the change in content size was detected.

It's their to reduce the impact of unintended loops locking up the browser, but that is not an issue here, as the second time it fires will trigger no action, as the iframe now matches the content size. Further to this iframe-resizer throttles all event handlers through the same code path, so it will only ever check content size once per animation frame anyway.

Looking at Sentry's own page about this warning, they basically recommend disabling the message.

Can I ask are you using cross domain or same domain iframes? I'm wondering if this is only an issue with same domain. Also have you seen this issue in earlier versions of iframe-resizer? Or is this the only version you have used?

Having just upgraded to Safari 18, I'm able to now see this warning message on the examples page of iframe-resizer.com.

A possible workaround to this would be to use requestAnimationFrame when the parent receives a message from the child to resize, but that comes at the cost of making animated content resizes slightly choppy. It also should not be necessary, as all resize events run through the same code pipeline and are already throttled to once per frame.

davidjbradshaw commented 2 days ago

I should also note that on the examples page, I'm deliberately causing an infinite resize loop with the CSS animation. On more normal pages I'm not seeing the warning message and it could also be that some of your users have a browser extension that is causing the issue.

KoanLeeroy commented 1 day ago

The iframes are cross-domain, and this is our first use of your code, so no prior versions/regressions known.

All I can safely say is that I do not see any perceived issued when I browse to the site in question, using the same device, OS and browser version as the user. I would be happy to pass to you a sample couple of sites that have reported the error, but would prefer to do so privately, somehow. Let me know if you are happy to do this and how we might be able to.

Am happy in principle to instruct Sentry to ignore these exceptions, but wanted to raise it for awareness.

davidjbradshaw commented 1 day ago

You can send stuff privately to info@iframe-resizer.com, I’m interested to take a look.

Do you see this warning on the examples page?