File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
packages/react-devtools-extensions/src Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,22 @@ const LOCAL_STORAGE_SUPPORTS_PROFILING_KEY =
30
30
const isChrome = getBrowserName ( ) === 'Chrome' ;
31
31
const isEdge = getBrowserName ( ) === 'Edge' ;
32
32
33
+ // since Chromium v102, requestAnimationFrame no longer fires in devtools_page (i.e. this file)
34
+ // mock requestAnimationFrame with setTimeout as a temporary workaround
35
+ // https://github.com/facebook/react/issues/24626
36
+ // The polyfill is based on https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
37
+ if ( isChrome || isEdge ) {
38
+ let lastTime = 0 ;
39
+ window . requestAnimationFrame = function ( callback , element ) {
40
+ const now = window . performance . now ( ) ;
41
+ const nextTime = Math . max ( lastTime + 16 , now ) ;
42
+ return setTimeout ( function ( ) {
43
+ callback ( ( lastTime = nextTime ) ) ;
44
+ } , nextTime - now ) ;
45
+ } ;
46
+ window . cancelAnimationFrame = clearTimeout ;
47
+ }
48
+
33
49
let panelCreated = false ;
34
50
35
51
// The renderer interface can't read saved component filters directly,
You can’t perform that action at this time.
0 commit comments