Skip to content

Commit

Permalink
fix SharedArrayBuffer when x-origin is enabled, copied from facebook#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Chambers committed Mar 10, 2021
1 parent 4337c1c commit b2bab63
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/scheduler/src/SchedulerProfiling.js
Expand Up @@ -15,13 +15,18 @@ import {NoPriority} from './SchedulerPriorities';
let runIdCounter: number = 0;
let mainThreadIdCounter: number = 0;

const isEnabledSharedArrayBuffer =
// $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function' &&
// We only use SharedArrayBuffer when cross origin isolation is enabled.
typeof window !== 'undefined' &&
window.crossOriginIsolated === true;

const profilingStateSize = 4;
export const sharedProfilingBuffer = enableProfiling
? // $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function'
? isEnabledSharedArrayBuffer
? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT)
: // $FlowFixMe Flow doesn't know about ArrayBuffer
typeof ArrayBuffer === 'function'
: typeof ArrayBuffer === 'function'
? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT)
: null // Don't crash the init path on IE9
: null;
Expand Down

0 comments on commit b2bab63

Please sign in to comment.