File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const PING_INTERVAL_MS = 14_225 ;
1+ const PING_INTERVAL_MS_1 = 13_225 ;
2+ const PING_INTERVAL_MS_2 = 17_765 ;
23
34/**
45 * scheduler 用于后台排程:Chrome 94+, Firefox 142+
@@ -34,10 +35,11 @@ export const startRepetitivePing = () => {
3435 const mutationObserver = new MutationObserver ( ( ) => {
3536 if ( isMutationPending ) {
3637 isMutationPending = false ;
38+ const pingIntervalMs = Math . random ( ) * ( PING_INTERVAL_MS_2 - PING_INTERVAL_MS_1 ) + PING_INTERVAL_MS_1 ;
3739 if ( nativeScheduler ) {
38- nativeScheduler . postTask ( pingTask , { priority : "background" , delay : PING_INTERVAL_MS } ) ;
40+ nativeScheduler . postTask ( pingTask , { priority : "background" , delay : pingIntervalMs } ) ;
3941 } else {
40- setTimeout ( pingTask , PING_INTERVAL_MS ) ;
42+ setTimeout ( pingTask , pingIntervalMs ) ;
4143 }
4244 }
4345 } ) ;
You can’t perform that action at this time.
0 commit comments