You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chrome recently turned on intensive timer throttling. The side-effect of this is that code that relied on timers firing at certain intervals may not work as expected. We first got reports of this issue with the SignalR Javascript library (dotnet/aspnetcore#31079), as it relies on client and server pings to detect connection closures. In addition, the SignalR .NET Client library has the same issue as it uses a timer to send the same pings.
The Javascript library was fixed by relying on
Intensive throttling is not applied to timers that are scheduled from a network response handler
Unfortunately, the .NET client can not do the same thing because it uses .NET patterns (async await) which go through the wasm runtime. The wasm runtime very likely uses timers for scheduling work which will be chained and have throttling applied to them.
Specifically, I was noticing that when using a System.IO.Pipeline, calling FlushAsync on a Pipe and ReadAsync from another thread was taking more than 30 seconds for the ReadAsync to return after FlushAsync finished.
TLDR:
Wasm Runtime uses timers which will be throttled on Chrome, this can result in poor behavior for apps.
A potential change that could be made is to restart timers on network handlers so they aren't throttled.
Thank you for the report, I'd seen some of discussion but hadn't connected all the pieces. Yes, we certainly use timers to yield to the browser while scheduling. We have a couple of options here that might help mitigate. Setting the milestone to 6 for the moment but it might be worth servicing.
I hope we can fix this before the 6.0 release. Anyone using Blazor Wasm with SignalR will be affected. I am ready to test a fix anytime :) Edge is affected too but it seems it has a 2 hour page idle time before the throttling kicks in.
We are currently investigating solutions for this issue. If you have specific problem scenarios (other than the already-known SignalR issue) or reliable reproduction steps it'd be good to know about them so we can make sure whatever solution we arrive at will address the problem for you.
It's the opposite, browser vendors are throttling everything and having an active network connection lets you avoid the worst of it
You misunderstood, I understand the issue, but the proposed PR is only for websocket connections. It would be better to apply the fix for any network activity.
We don't have a simple way to do that since other types of network activity don't go through our runtime layer, only WebSocket does. We could potentially install hooks on fetch, XMLHTTPRequest, and WebRTC, but that's some new engineering with associated risk. It sounds like a good idea so it might be worth filing an issue.
All networking goes through our code. Http goes through our fetch hooks (we don't bind xmlhttprequest intentionally).
It's the opposite, browser vendors are throttling everything and having an active network connection lets you avoid the worst of it
You misunderstood, I understand the issue, but the proposed PR is only for websocket connections. It would be better to apply the fix for any network activity.
We don't have a simple way to do that since other types of network activity don't go through our runtime layer, only WebSocket does. We could potentially install hooks on fetch, XMLHTTPRequest, and WebRTC, but that's some new engineering with associated risk. It sounds like a good idea so it might be worth filing an issue.
All networking goes through our code. Http goes through our fetch hooks (we don't bind xmlhttprequest intentionally).
I'm referring to things like third-party libraries that might be calling directly into JS
The documentation I found so far only speaks about WebRTC as opt-out. We know from experience that WebSocket has same effect. Could you point me to something specific talking about fetch or XMLHTTPRequest in this context ?
I will experiment with back end of the fetch promise when called by our BrowserHttpHandler and see if that works too.
I don't think we should monkey-patch window.fetch to hook into third party JS.
Timer throttling is caused by chained timers, if you kick off a new timer from any network response you will no longer have chained timers. Thus avoiding the throttling issue (at least until they add some new heuristic)
Timer throttling is caused by chained timers, if you kick off a new timer from any network response you will no longer have chained timers. Thus avoiding the throttling issue (at least until they add some new heuristic)
Response to fetch is not event, but just promise.
I implemented hook into that promise and test here pavelsavara@425252b
But unfortunately, it does NOT prevent throttling.
@BrennanConroy could you please look at my code to verify I have not made some simple mistake ? Or alternatively, could you please provide demo on which fetch prevents throttling ?
Activity
lewing commentedon Apr 10, 2021
Thank you for the report, I'd seen some of discussion but hadn't connected all the pieces. Yes, we certainly use timers to yield to the browser while scheduling. We have a couple of options here that might help mitigate. Setting the milestone to 6 for the moment but it might be worth servicing.
cc @kg @pavelsavara
WayneHiller commentedon Apr 13, 2021
I hope we can fix this before the 6.0 release. Anyone using Blazor Wasm with SignalR will be affected. I am ready to test a fix anytime :) Edge is affected too but it seems it has a 2 hour page idle time before the throttling kicks in.
andrew-tevent commentedon Apr 13, 2021
These stability issues are causing us issues, so a .net 5 backport would be gratefully received.
tofron commentedon Apr 21, 2021
I have the same issue. i'm using 3.1.14 version
kg commentedon Apr 21, 2021
We are currently investigating solutions for this issue. If you have specific problem scenarios (other than the already-known SignalR issue) or reliable reproduction steps it'd be good to know about them so we can make sure whatever solution we arrive at will address the problem for you.
andrew-tevent commentedon Apr 29, 2021
@kg I added a Chrome WS messages screenshot here.
pavelsavara commentedon May 5, 2021
I created simple JS only app on which it could be tested, how it behaves https://github.com/pavelsavara/timer-throttle
25 remaining items
lewing commentedon Aug 24, 2021
All networking goes through our code. Http goes through our fetch hooks (we don't bind xmlhttprequest intentionally).
kg commentedon Aug 24, 2021
I'm referring to things like third-party libraries that might be calling directly into JS
pavelsavara commentedon Aug 24, 2021
https://superuser.com/questions/1500289/how-to-aggressively-throttle-background-tabs-in-firefox-using-dom-min-background
I guess that if we deplete the budget we would be throttled. But in my tests it didn't happen. Perhaps some CPU heavy workload could trigger that.
The documentation I found so far only speaks about
WebRTCas opt-out. We know from experience thatWebSockethas same effect. Could you point me to something specific talking aboutfetchorXMLHTTPRequestin this context ?I will experiment with back end of the
fetchpromise when called by ourBrowserHttpHandlerand see if that works too.I don't think we should monkey-patch
window.fetchto hook into third party JS.BrennanConroy commentedon Aug 24, 2021
Timer throttling is caused by chained timers, if you kick off a new timer from any network response you will no longer have chained timers. Thus avoiding the throttling issue (at least until they add some new heuristic)
pavelsavara commentedon Aug 24, 2021
Response to fetch is not event, but just promise.
I implemented hook into that promise and test here pavelsavara@425252b
But unfortunately, it does NOT prevent throttling.
@BrennanConroy could you please look at my code to verify I have not made some simple mistake ? Or alternatively, could you please provide demo on which
fetchprevents throttling ?BrennanConroy commentedon Aug 24, 2021
Oh I see, that is unfortunate 😞
pavelsavara commentedon Aug 26, 2021
Keep open till 6.0 backport is done
karelz commentedon Aug 26, 2021
Fixed in 6.0 RC1 in PR #58160.
Fixed in 7.0 in PR #57745