4

I created a react app that sends XHR requests (frames from webcam) at a high rate (about 10 calls per second)

When I ran this app from an iframe the rate drops to 1 call per second

However, if I move the mouse over the iframe the rate of the XHR requests jumps back to 10 calls per second

How can I get the high rate inside the iframe without moving the mouse over the iframe?

Nimrod Borochov
  • 356
  • 3
  • 17
  • Sounds phishi.. – Tal Rofe Jun 22 '22 at 15:36
  • Probably related: https://stackoverflow.com/questions/15871942/how-do-browsers-pause-change-javascript-when-tab-or-window-is-not-active – Quentin Jun 22 '22 at 15:41
  • 1
    Making 10 HTTP requests a second sounds like a terrible solution to any problem. I'd look at addressing this by sticking the frames together (server-side) into something that actually streams (I'd look at [MJPEG if support was better](https://stackoverflow.com/questions/37239869/mjpeg-html5-video-doesnt-stream-with-video)). – Quentin Jun 22 '22 at 15:43
  • have you tried different browsers (ie engines)? I would wager that the iframe is classed as a background/unfocussed tab, hence why it is given lower priority - somthing like https://blog.chromium.org/2020/11/tab-throttling-and-more-performance.html being the culprit – JoSSte Jul 01 '22 at 14:55
  • Have you tried use `loading="eager"` attribute to your iframe ? – hugomztl Jul 01 '22 at 15:00
  • @JoSSte yes, in safari & firefox the requests are at a high rate as expected – Nimrod Borochov Jul 03 '22 at 05:25
  • @hugomztl yes I have tried loading="eager" (didn't work) – Nimrod Borochov Jul 03 '22 at 05:25

0 Answers0