scheduler 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-info.json +4 -4
- package/cjs/scheduler-tracing.development.js +11 -17
- package/cjs/scheduler-tracing.production.min.js +1 -1
- package/cjs/scheduler-tracing.profiling.min.js +1 -1
- package/cjs/scheduler-unstable_mock.development.js +20 -18
- package/cjs/scheduler-unstable_mock.production.min.js +1 -1
- package/cjs/scheduler.development.js +75 -193
- package/cjs/scheduler.production.min.js +12 -12
- package/package.json +1 -1
- package/umd/scheduler-unstable_mock.development.js +20 -18
- package/umd/scheduler-unstable_mock.production.min.js +1 -1
package/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"branch": "master",
|
|
3
|
-
"buildNumber": "
|
|
4
|
-
"checksum": "
|
|
5
|
-
"commit": "
|
|
3
|
+
"buildNumber": "59518",
|
|
4
|
+
"checksum": "6f449c4",
|
|
5
|
+
"commit": "b53ea6ca0",
|
|
6
6
|
"environment": "ci",
|
|
7
|
-
"reactVersion": "16.
|
|
7
|
+
"reactVersion": "16.11.0-b53ea6ca0"
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.
|
|
1
|
+
/** @license React v0.18.0
|
|
2
2
|
* scheduler-tracing.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -17,12 +17,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
19
19
|
|
|
20
|
-
// Helps identify side effects in
|
|
21
|
-
|
|
22
|
-
// In some cases, StrictMode should also double-render lifecycles.
|
|
23
|
-
// This can be confusing for tests though,
|
|
24
|
-
// And it can be bad for performance in production.
|
|
25
|
-
// This feature flag can be used to control the behavior:
|
|
20
|
+
// Helps identify side effects in render-phase lifecycle hooks and setState
|
|
21
|
+
// reducers by double invoking them in Strict Mode.
|
|
26
22
|
|
|
27
23
|
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
28
24
|
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
@@ -33,9 +29,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
33
29
|
|
|
34
30
|
// Trace which interactions trigger each commit.
|
|
35
31
|
|
|
36
|
-
var enableSchedulerTracing = true; //
|
|
32
|
+
var enableSchedulerTracing = true; // SSR experiments
|
|
37
33
|
|
|
38
|
-
// TODO: true? Here it might just be false.
|
|
39
34
|
|
|
40
35
|
// Only used in www builds.
|
|
41
36
|
|
|
@@ -50,9 +45,6 @@ var enableSchedulerTracing = true; // Only used in www builds.
|
|
|
50
45
|
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
|
|
51
46
|
|
|
52
47
|
|
|
53
|
-
// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
|
|
54
|
-
// This is a flag so we can fix warnings in RN core before turning it on
|
|
55
|
-
|
|
56
48
|
// Experimental React Flare event system and event components support.
|
|
57
49
|
|
|
58
50
|
// Experimental Host Component support.
|
|
@@ -62,15 +54,11 @@ var enableSchedulerTracing = true; // Only used in www builds.
|
|
|
62
54
|
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
|
63
55
|
|
|
64
56
|
// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
|
|
65
|
-
// Till then, we warn about the missing mock, but still fallback to a
|
|
57
|
+
// Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version
|
|
66
58
|
|
|
67
59
|
// For tests, we flush suspense fallbacks in an act scope;
|
|
68
60
|
// *except* in some of our own tests, where we test incremental loading states.
|
|
69
61
|
|
|
70
|
-
// Changes priority of some events like mousemove to user-blocking priority,
|
|
71
|
-
// but without making them discrete. The flag exists in case it causes
|
|
72
|
-
// starvation problems.
|
|
73
|
-
|
|
74
62
|
// Add a callback property to suspense to notify which promises are currently
|
|
75
63
|
// in the update queue. This allows reporting and tracing of what is causing
|
|
76
64
|
// the user to see a loading state.
|
|
@@ -81,6 +69,12 @@ var enableSchedulerTracing = true; // Only used in www builds.
|
|
|
81
69
|
// from React.createElement to React.jsx
|
|
82
70
|
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
|
|
83
71
|
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance
|
|
77
|
+
|
|
84
78
|
var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.
|
|
85
79
|
|
|
86
80
|
var interactionIDCounter = 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.
|
|
1
|
+
/** @license React v0.18.0
|
|
2
2
|
* scheduler-unstable_mock.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -19,7 +19,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
19
19
|
|
|
20
20
|
var enableSchedulerDebugging = false;
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
var enableProfiling = true;
|
|
24
23
|
|
|
25
24
|
var currentTime = 0;
|
|
@@ -374,47 +373,50 @@ function stopLoggingProfilingEvents() {
|
|
|
374
373
|
eventLogIndex = 0;
|
|
375
374
|
return buffer;
|
|
376
375
|
}
|
|
377
|
-
function markTaskStart(task,
|
|
376
|
+
function markTaskStart(task, ms) {
|
|
378
377
|
if (enableProfiling) {
|
|
379
378
|
profilingState[QUEUE_SIZE]++;
|
|
380
379
|
|
|
381
380
|
if (eventLog !== null) {
|
|
382
|
-
|
|
381
|
+
// performance.now returns a float, representing milliseconds. When the
|
|
382
|
+
// event is logged, it's coerced to an int. Convert to microseconds to
|
|
383
|
+
// maintain extra degrees of precision.
|
|
384
|
+
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
|
|
383
385
|
}
|
|
384
386
|
}
|
|
385
387
|
}
|
|
386
|
-
function markTaskCompleted(task,
|
|
388
|
+
function markTaskCompleted(task, ms) {
|
|
387
389
|
if (enableProfiling) {
|
|
388
390
|
profilingState[PRIORITY] = NoPriority;
|
|
389
391
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
390
392
|
profilingState[QUEUE_SIZE]--;
|
|
391
393
|
|
|
392
394
|
if (eventLog !== null) {
|
|
393
|
-
logEvent([TaskCompleteEvent,
|
|
395
|
+
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
|
|
394
396
|
}
|
|
395
397
|
}
|
|
396
398
|
}
|
|
397
|
-
function markTaskCanceled(task,
|
|
399
|
+
function markTaskCanceled(task, ms) {
|
|
398
400
|
if (enableProfiling) {
|
|
399
401
|
profilingState[QUEUE_SIZE]--;
|
|
400
402
|
|
|
401
403
|
if (eventLog !== null) {
|
|
402
|
-
logEvent([TaskCancelEvent,
|
|
404
|
+
logEvent([TaskCancelEvent, ms * 1000, task.id]);
|
|
403
405
|
}
|
|
404
406
|
}
|
|
405
407
|
}
|
|
406
|
-
function markTaskErrored(task,
|
|
408
|
+
function markTaskErrored(task, ms) {
|
|
407
409
|
if (enableProfiling) {
|
|
408
410
|
profilingState[PRIORITY] = NoPriority;
|
|
409
411
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
410
412
|
profilingState[QUEUE_SIZE]--;
|
|
411
413
|
|
|
412
414
|
if (eventLog !== null) {
|
|
413
|
-
logEvent([TaskErrorEvent,
|
|
415
|
+
logEvent([TaskErrorEvent, ms * 1000, task.id]);
|
|
414
416
|
}
|
|
415
417
|
}
|
|
416
418
|
}
|
|
417
|
-
function markTaskRun(task,
|
|
419
|
+
function markTaskRun(task, ms) {
|
|
418
420
|
if (enableProfiling) {
|
|
419
421
|
runIdCounter++;
|
|
420
422
|
profilingState[PRIORITY] = task.priorityLevel;
|
|
@@ -422,34 +424,34 @@ function markTaskRun(task, time) {
|
|
|
422
424
|
profilingState[CURRENT_RUN_ID] = runIdCounter;
|
|
423
425
|
|
|
424
426
|
if (eventLog !== null) {
|
|
425
|
-
logEvent([TaskRunEvent,
|
|
427
|
+
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
|
|
426
428
|
}
|
|
427
429
|
}
|
|
428
430
|
}
|
|
429
|
-
function markTaskYield(task,
|
|
431
|
+
function markTaskYield(task, ms) {
|
|
430
432
|
if (enableProfiling) {
|
|
431
433
|
profilingState[PRIORITY] = NoPriority;
|
|
432
434
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
433
435
|
profilingState[CURRENT_RUN_ID] = 0;
|
|
434
436
|
|
|
435
437
|
if (eventLog !== null) {
|
|
436
|
-
logEvent([TaskYieldEvent,
|
|
438
|
+
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
|
|
437
439
|
}
|
|
438
440
|
}
|
|
439
441
|
}
|
|
440
|
-
function markSchedulerSuspended(
|
|
442
|
+
function markSchedulerSuspended(ms) {
|
|
441
443
|
if (enableProfiling) {
|
|
442
444
|
mainThreadIdCounter++;
|
|
443
445
|
|
|
444
446
|
if (eventLog !== null) {
|
|
445
|
-
logEvent([SchedulerSuspendEvent,
|
|
447
|
+
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
|
|
446
448
|
}
|
|
447
449
|
}
|
|
448
450
|
}
|
|
449
|
-
function markSchedulerUnsuspended(
|
|
451
|
+
function markSchedulerUnsuspended(ms) {
|
|
450
452
|
if (enableProfiling) {
|
|
451
453
|
if (eventLog !== null) {
|
|
452
|
-
logEvent([SchedulerResumeEvent,
|
|
454
|
+
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
|
|
453
455
|
}
|
|
454
456
|
}
|
|
455
457
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.
|
|
1
|
+
/** @license React v0.18.0
|
|
2
2
|
* scheduler.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -19,16 +19,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
19
19
|
|
|
20
20
|
var enableSchedulerDebugging = false;
|
|
21
21
|
var enableIsInputPending = false;
|
|
22
|
-
var enableMessageLoopImplementation = true;
|
|
23
22
|
var enableProfiling = true;
|
|
24
23
|
|
|
25
|
-
// works by scheduling a requestAnimationFrame, storing the time for the start
|
|
26
|
-
// of the frame, then scheduling a postMessage which gets scheduled after paint.
|
|
27
|
-
// Within the postMessage handler do as much work as possible until time + frame
|
|
28
|
-
// rate. By separating the idle call into a separate event tick we ensure that
|
|
29
|
-
// layout, paint and other browser work is counted against the available time.
|
|
30
|
-
// The frame rate is dynamically adjusted.
|
|
31
|
-
|
|
32
24
|
var requestHostCallback;
|
|
33
25
|
|
|
34
26
|
var requestHostTimeout;
|
|
@@ -98,11 +90,14 @@ typeof MessageChannel !== 'function') {
|
|
|
98
90
|
var _Date = window.Date;
|
|
99
91
|
var _setTimeout = window.setTimeout;
|
|
100
92
|
var _clearTimeout = window.clearTimeout;
|
|
101
|
-
var requestAnimationFrame = window.requestAnimationFrame;
|
|
102
|
-
var cancelAnimationFrame = window.cancelAnimationFrame;
|
|
103
93
|
|
|
104
94
|
if (typeof console !== 'undefined') {
|
|
105
|
-
// TODO:
|
|
95
|
+
// TODO: Scheduler no longer requires these methods to be polyfilled. But
|
|
96
|
+
// maybe we want to continue warning if they don't exist, to preserve the
|
|
97
|
+
// option to rely on it in the future?
|
|
98
|
+
var requestAnimationFrame = window.requestAnimationFrame;
|
|
99
|
+
var cancelAnimationFrame = window.cancelAnimationFrame; // TODO: Remove fb.me link
|
|
100
|
+
|
|
106
101
|
if (typeof requestAnimationFrame !== 'function') {
|
|
107
102
|
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
|
108
103
|
}
|
|
@@ -124,26 +119,18 @@ typeof MessageChannel !== 'function') {
|
|
|
124
119
|
};
|
|
125
120
|
}
|
|
126
121
|
|
|
127
|
-
var isRAFLoopRunning = false;
|
|
128
122
|
var isMessageLoopRunning = false;
|
|
129
123
|
var scheduledHostCallback = null;
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// heuristic tracking will adjust this value to a faster fps if we get
|
|
138
|
-
// more frequent animation frames.
|
|
139
|
-
33.33;
|
|
140
|
-
var prevRAFTime = -1;
|
|
141
|
-
var prevRAFInterval = -1;
|
|
142
|
-
var frameDeadline = 0;
|
|
143
|
-
var fpsLocked = false; // TODO: Make this configurable
|
|
124
|
+
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
|
|
125
|
+
// thread, like user events. By default, it yields multiple times per frame.
|
|
126
|
+
// It does not attempt to align with frame boundaries, since most tasks don't
|
|
127
|
+
// need to be frame aligned; for those that do, use requestAnimationFrame.
|
|
128
|
+
|
|
129
|
+
var yieldInterval = 5;
|
|
130
|
+
var deadline = 0; // TODO: Make this configurable
|
|
144
131
|
// TODO: Adjust this based on priority?
|
|
145
132
|
|
|
146
|
-
var
|
|
133
|
+
var maxYieldInterval = 300;
|
|
147
134
|
var needsPaint = false;
|
|
148
135
|
|
|
149
136
|
if (enableIsInputPending && navigator !== undefined && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined) {
|
|
@@ -152,23 +139,23 @@ typeof MessageChannel !== 'function') {
|
|
|
152
139
|
shouldYieldToHost = function () {
|
|
153
140
|
var currentTime = exports.unstable_now();
|
|
154
141
|
|
|
155
|
-
if (currentTime >=
|
|
156
|
-
// There's no time left
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
142
|
+
if (currentTime >= deadline) {
|
|
143
|
+
// There's no time left. We may want to yield control of the main
|
|
144
|
+
// thread, so the browser can perform high priority tasks. The main ones
|
|
145
|
+
// are painting and user input. If there's a pending paint or a pending
|
|
146
|
+
// input, then we should yield. But if there's neither, then we can
|
|
147
|
+
// yield less often while remaining responsive. We'll eventually yield
|
|
148
|
+
// regardless, since there could be a pending paint that wasn't
|
|
162
149
|
// accompanied by a call to `requestPaint`, or other main thread tasks
|
|
163
150
|
// like network events.
|
|
164
151
|
if (needsPaint || scheduling.isInputPending()) {
|
|
165
152
|
// There is either a pending paint or a pending input.
|
|
166
153
|
return true;
|
|
167
154
|
} // There's no pending input. Only yield if we've reached the max
|
|
168
|
-
//
|
|
155
|
+
// yield interval.
|
|
169
156
|
|
|
170
157
|
|
|
171
|
-
return currentTime >=
|
|
158
|
+
return currentTime >= maxYieldInterval;
|
|
172
159
|
} else {
|
|
173
160
|
// There's still time left in the frame.
|
|
174
161
|
return false;
|
|
@@ -182,7 +169,7 @@ typeof MessageChannel !== 'function') {
|
|
|
182
169
|
// `isInputPending` is not available. Since we have no way of knowing if
|
|
183
170
|
// there's pending input, always yield at the end of the frame.
|
|
184
171
|
shouldYieldToHost = function () {
|
|
185
|
-
return exports.unstable_now() >=
|
|
172
|
+
return exports.unstable_now() >= deadline;
|
|
186
173
|
}; // Since we yield every frame regardless, `requestPaint` has no effect.
|
|
187
174
|
|
|
188
175
|
|
|
@@ -196,166 +183,58 @@ typeof MessageChannel !== 'function') {
|
|
|
196
183
|
}
|
|
197
184
|
|
|
198
185
|
if (fps > 0) {
|
|
199
|
-
|
|
200
|
-
fpsLocked = true;
|
|
186
|
+
yieldInterval = Math.floor(1000 / fps);
|
|
201
187
|
} else {
|
|
202
188
|
// reset the framerate
|
|
203
|
-
|
|
204
|
-
fpsLocked = false;
|
|
189
|
+
yieldInterval = 5;
|
|
205
190
|
}
|
|
206
191
|
};
|
|
207
192
|
|
|
208
193
|
var performWorkUntilDeadline = function () {
|
|
209
|
-
if (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
// the message event.
|
|
214
|
-
|
|
215
|
-
frameDeadline = currentTime + frameLength;
|
|
216
|
-
var hasTimeRemaining = true;
|
|
217
|
-
|
|
218
|
-
try {
|
|
219
|
-
var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
|
|
220
|
-
|
|
221
|
-
if (!hasMoreWork) {
|
|
222
|
-
isMessageLoopRunning = false;
|
|
223
|
-
scheduledHostCallback = null;
|
|
224
|
-
} else {
|
|
225
|
-
// If there's more work, schedule the next message event at the end
|
|
226
|
-
// of the preceding one.
|
|
227
|
-
port.postMessage(null);
|
|
228
|
-
}
|
|
229
|
-
} catch (error) {
|
|
230
|
-
// If a scheduler task throws, exit the current browser task so the
|
|
231
|
-
// error can be observed.
|
|
232
|
-
port.postMessage(null);
|
|
233
|
-
throw error;
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
isMessageLoopRunning = false;
|
|
237
|
-
} // Yielding to the browser will give it a chance to paint, so we can
|
|
238
|
-
// reset this.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
needsPaint = false;
|
|
242
|
-
} else {
|
|
243
|
-
if (scheduledHostCallback !== null) {
|
|
244
|
-
var _currentTime = exports.unstable_now();
|
|
245
|
-
|
|
246
|
-
var _hasTimeRemaining = frameDeadline - _currentTime > 0;
|
|
194
|
+
if (scheduledHostCallback !== null) {
|
|
195
|
+
var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync
|
|
196
|
+
// cycle. This means there's always time remaining at the beginning of
|
|
197
|
+
// the message event.
|
|
247
198
|
|
|
248
|
-
|
|
249
|
-
|
|
199
|
+
deadline = currentTime + yieldInterval;
|
|
200
|
+
var hasTimeRemaining = true;
|
|
250
201
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
202
|
+
try {
|
|
203
|
+
var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
|
|
204
|
+
|
|
205
|
+
if (!hasMoreWork) {
|
|
206
|
+
isMessageLoopRunning = false;
|
|
207
|
+
scheduledHostCallback = null;
|
|
208
|
+
} else {
|
|
209
|
+
// If there's more work, schedule the next message event at the end
|
|
210
|
+
// of the preceding one.
|
|
258
211
|
port.postMessage(null);
|
|
259
|
-
throw error;
|
|
260
212
|
}
|
|
261
|
-
}
|
|
262
|
-
|
|
213
|
+
} catch (error) {
|
|
214
|
+
// If a scheduler task throws, exit the current browser task so the
|
|
215
|
+
// error can be observed.
|
|
216
|
+
port.postMessage(null);
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
isMessageLoopRunning = false;
|
|
221
|
+
} // Yielding to the browser will give it a chance to paint, so we can
|
|
222
|
+
// reset this.
|
|
263
223
|
|
|
264
224
|
|
|
265
|
-
|
|
266
|
-
}
|
|
225
|
+
needsPaint = false;
|
|
267
226
|
};
|
|
268
227
|
|
|
269
228
|
var channel = new MessageChannel();
|
|
270
229
|
var port = channel.port2;
|
|
271
230
|
channel.port1.onmessage = performWorkUntilDeadline;
|
|
272
231
|
|
|
273
|
-
var onAnimationFrame = function (rAFTime) {
|
|
274
|
-
if (scheduledHostCallback === null) {
|
|
275
|
-
// No scheduled work. Exit.
|
|
276
|
-
prevRAFTime = -1;
|
|
277
|
-
prevRAFInterval = -1;
|
|
278
|
-
isRAFLoopRunning = false;
|
|
279
|
-
return;
|
|
280
|
-
} // Eagerly schedule the next animation callback at the beginning of the
|
|
281
|
-
// frame. If the scheduler queue is not empty at the end of the frame, it
|
|
282
|
-
// will continue flushing inside that callback. If the queue *is* empty,
|
|
283
|
-
// then it will exit immediately. Posting the callback at the start of the
|
|
284
|
-
// frame ensures it's fired within the earliest possible frame. If we
|
|
285
|
-
// waited until the end of the frame to post the callback, we risk the
|
|
286
|
-
// browser skipping a frame and not firing the callback until the frame
|
|
287
|
-
// after that.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
isRAFLoopRunning = true;
|
|
291
|
-
requestAnimationFrame(function (nextRAFTime) {
|
|
292
|
-
_clearTimeout(rAFTimeoutID);
|
|
293
|
-
|
|
294
|
-
onAnimationFrame(nextRAFTime);
|
|
295
|
-
}); // requestAnimationFrame is throttled when the tab is backgrounded. We
|
|
296
|
-
// don't want to stop working entirely. So we'll fallback to a timeout loop.
|
|
297
|
-
// TODO: Need a better heuristic for backgrounded work.
|
|
298
|
-
|
|
299
|
-
var onTimeout = function () {
|
|
300
|
-
frameDeadline = exports.unstable_now() + frameLength / 2;
|
|
301
|
-
performWorkUntilDeadline();
|
|
302
|
-
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
|
|
306
|
-
|
|
307
|
-
if (prevRAFTime !== -1 && // Make sure this rAF time is different from the previous one. This check
|
|
308
|
-
// could fail if two rAFs fire in the same frame.
|
|
309
|
-
rAFTime - prevRAFTime > 0.1) {
|
|
310
|
-
var rAFInterval = rAFTime - prevRAFTime;
|
|
311
|
-
|
|
312
|
-
if (!fpsLocked && prevRAFInterval !== -1) {
|
|
313
|
-
// We've observed two consecutive frame intervals. We'll use this to
|
|
314
|
-
// dynamically adjust the frame rate.
|
|
315
|
-
//
|
|
316
|
-
// If one frame goes long, then the next one can be short to catch up.
|
|
317
|
-
// If two frames are short in a row, then that's an indication that we
|
|
318
|
-
// actually have a higher frame rate than what we're currently
|
|
319
|
-
// optimizing. For example, if we're running on 120hz display or 90hz VR
|
|
320
|
-
// display. Take the max of the two in case one of them was an anomaly
|
|
321
|
-
// due to missed frame deadlines.
|
|
322
|
-
if (rAFInterval < frameLength && prevRAFInterval < frameLength) {
|
|
323
|
-
frameLength = rAFInterval < prevRAFInterval ? prevRAFInterval : rAFInterval;
|
|
324
|
-
|
|
325
|
-
if (frameLength < 8.33) {
|
|
326
|
-
// Defensive coding. We don't support higher frame rates than 120hz.
|
|
327
|
-
// If the calculated frame length gets lower than 8, it is probably
|
|
328
|
-
// a bug.
|
|
329
|
-
frameLength = 8.33;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
prevRAFInterval = rAFInterval;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
prevRAFTime = rAFTime;
|
|
338
|
-
frameDeadline = rAFTime + frameLength; // We use the postMessage trick to defer idle work until after the repaint.
|
|
339
|
-
|
|
340
|
-
port.postMessage(null);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
232
|
requestHostCallback = function (callback) {
|
|
344
233
|
scheduledHostCallback = callback;
|
|
345
234
|
|
|
346
|
-
if (
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
port.postMessage(null);
|
|
350
|
-
}
|
|
351
|
-
} else {
|
|
352
|
-
if (!isRAFLoopRunning) {
|
|
353
|
-
// Start a rAF loop.
|
|
354
|
-
isRAFLoopRunning = true;
|
|
355
|
-
requestAnimationFrame(function (rAFTime) {
|
|
356
|
-
onAnimationFrame(rAFTime);
|
|
357
|
-
});
|
|
358
|
-
}
|
|
235
|
+
if (!isMessageLoopRunning) {
|
|
236
|
+
isMessageLoopRunning = true;
|
|
237
|
+
port.postMessage(null);
|
|
359
238
|
}
|
|
360
239
|
};
|
|
361
240
|
|
|
@@ -539,47 +418,50 @@ function stopLoggingProfilingEvents() {
|
|
|
539
418
|
eventLogIndex = 0;
|
|
540
419
|
return buffer;
|
|
541
420
|
}
|
|
542
|
-
function markTaskStart(task,
|
|
421
|
+
function markTaskStart(task, ms) {
|
|
543
422
|
if (enableProfiling) {
|
|
544
423
|
profilingState[QUEUE_SIZE]++;
|
|
545
424
|
|
|
546
425
|
if (eventLog !== null) {
|
|
547
|
-
|
|
426
|
+
// performance.now returns a float, representing milliseconds. When the
|
|
427
|
+
// event is logged, it's coerced to an int. Convert to microseconds to
|
|
428
|
+
// maintain extra degrees of precision.
|
|
429
|
+
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
|
|
548
430
|
}
|
|
549
431
|
}
|
|
550
432
|
}
|
|
551
|
-
function markTaskCompleted(task,
|
|
433
|
+
function markTaskCompleted(task, ms) {
|
|
552
434
|
if (enableProfiling) {
|
|
553
435
|
profilingState[PRIORITY] = NoPriority;
|
|
554
436
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
555
437
|
profilingState[QUEUE_SIZE]--;
|
|
556
438
|
|
|
557
439
|
if (eventLog !== null) {
|
|
558
|
-
logEvent([TaskCompleteEvent,
|
|
440
|
+
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
|
|
559
441
|
}
|
|
560
442
|
}
|
|
561
443
|
}
|
|
562
|
-
function markTaskCanceled(task,
|
|
444
|
+
function markTaskCanceled(task, ms) {
|
|
563
445
|
if (enableProfiling) {
|
|
564
446
|
profilingState[QUEUE_SIZE]--;
|
|
565
447
|
|
|
566
448
|
if (eventLog !== null) {
|
|
567
|
-
logEvent([TaskCancelEvent,
|
|
449
|
+
logEvent([TaskCancelEvent, ms * 1000, task.id]);
|
|
568
450
|
}
|
|
569
451
|
}
|
|
570
452
|
}
|
|
571
|
-
function markTaskErrored(task,
|
|
453
|
+
function markTaskErrored(task, ms) {
|
|
572
454
|
if (enableProfiling) {
|
|
573
455
|
profilingState[PRIORITY] = NoPriority;
|
|
574
456
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
575
457
|
profilingState[QUEUE_SIZE]--;
|
|
576
458
|
|
|
577
459
|
if (eventLog !== null) {
|
|
578
|
-
logEvent([TaskErrorEvent,
|
|
460
|
+
logEvent([TaskErrorEvent, ms * 1000, task.id]);
|
|
579
461
|
}
|
|
580
462
|
}
|
|
581
463
|
}
|
|
582
|
-
function markTaskRun(task,
|
|
464
|
+
function markTaskRun(task, ms) {
|
|
583
465
|
if (enableProfiling) {
|
|
584
466
|
runIdCounter++;
|
|
585
467
|
profilingState[PRIORITY] = task.priorityLevel;
|
|
@@ -587,34 +469,34 @@ function markTaskRun(task, time) {
|
|
|
587
469
|
profilingState[CURRENT_RUN_ID] = runIdCounter;
|
|
588
470
|
|
|
589
471
|
if (eventLog !== null) {
|
|
590
|
-
logEvent([TaskRunEvent,
|
|
472
|
+
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
|
|
591
473
|
}
|
|
592
474
|
}
|
|
593
475
|
}
|
|
594
|
-
function markTaskYield(task,
|
|
476
|
+
function markTaskYield(task, ms) {
|
|
595
477
|
if (enableProfiling) {
|
|
596
478
|
profilingState[PRIORITY] = NoPriority;
|
|
597
479
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
598
480
|
profilingState[CURRENT_RUN_ID] = 0;
|
|
599
481
|
|
|
600
482
|
if (eventLog !== null) {
|
|
601
|
-
logEvent([TaskYieldEvent,
|
|
483
|
+
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
|
|
602
484
|
}
|
|
603
485
|
}
|
|
604
486
|
}
|
|
605
|
-
function markSchedulerSuspended(
|
|
487
|
+
function markSchedulerSuspended(ms) {
|
|
606
488
|
if (enableProfiling) {
|
|
607
489
|
mainThreadIdCounter++;
|
|
608
490
|
|
|
609
491
|
if (eventLog !== null) {
|
|
610
|
-
logEvent([SchedulerSuspendEvent,
|
|
492
|
+
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
|
|
611
493
|
}
|
|
612
494
|
}
|
|
613
495
|
}
|
|
614
|
-
function markSchedulerUnsuspended(
|
|
496
|
+
function markSchedulerUnsuspended(ms) {
|
|
615
497
|
if (enableProfiling) {
|
|
616
498
|
if (eventLog !== null) {
|
|
617
|
-
logEvent([SchedulerResumeEvent,
|
|
499
|
+
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
|
|
618
500
|
}
|
|
619
501
|
}
|
|
620
502
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.
|
|
1
|
+
/** @license React v0.18.0
|
|
2
2
|
* scheduler.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
|
|
10
10
|
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var f,g,h,k,l;
|
|
11
11
|
if("undefined"===typeof window||"function"!==typeof MessageChannel){var p=null,q=null,t=function(){if(null!==p)try{var a=exports.unstable_now();p(!0,a);p=null}catch(b){throw setTimeout(t,0),b;}},u=Date.now();exports.unstable_now=function(){return Date.now()-u};f=function(a){null!==p?setTimeout(f,0,a):(p=a,setTimeout(t,0))};g=function(a,b){q=setTimeout(a,b)};h=function(){clearTimeout(q)};k=function(){return!1};l=exports.unstable_forceFrameRate=function(){}}else{var w=window.performance,x=window.Date,
|
|
12
|
-
y=window.setTimeout,z=window.clearTimeout
|
|
13
|
-
"function"===typeof w.now)exports.unstable_now=function(){return w.now()};else{var
|
|
14
|
-
function(){if(null!==
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
function
|
|
19
|
-
exports.unstable_next=function(a){switch(
|
|
20
|
-
exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();if("object"===typeof c&&null!==c){var e=c.delay;e="number"===typeof e&&0<e?d+e:d;c="number"===typeof c.timeout?c.timeout:
|
|
21
|
-
exports.unstable_wrapCallback=function(a){var b=
|
|
22
|
-
exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return
|
|
12
|
+
y=window.setTimeout,z=window.clearTimeout;if("undefined"!==typeof console){var A=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills");"function"!==typeof A&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills")}if("object"===
|
|
13
|
+
typeof w&&"function"===typeof w.now)exports.unstable_now=function(){return w.now()};else{var B=x.now();exports.unstable_now=function(){return x.now()-B}}var C=!1,D=null,E=-1,F=5,G=0;k=function(){return exports.unstable_now()>=G};l=function(){};exports.unstable_forceFrameRate=function(a){0>a||125<a?console.error("forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported"):F=0<a?Math.floor(1E3/a):5};var H=new MessageChannel,I=H.port2;H.port1.onmessage=
|
|
14
|
+
function(){if(null!==D){var a=exports.unstable_now();G=a+F;try{D(!0,a)?I.postMessage(null):(C=!1,D=null)}catch(b){throw I.postMessage(null),b;}}else C=!1};f=function(a){D=a;C||(C=!0,I.postMessage(null))};g=function(a,b){E=y(function(){a(exports.unstable_now())},b)};h=function(){z(E);E=-1}}function J(a,b){var c=a.length;a.push(b);a:for(;;){var d=Math.floor((c-1)/2),e=a[d];if(void 0!==e&&0<K(e,b))a[d]=b,a[c]=e,c=d;else break a}}function L(a){a=a[0];return void 0===a?null:a}
|
|
15
|
+
function M(a){var b=a[0];if(void 0!==b){var c=a.pop();if(c!==b){a[0]=c;a:for(var d=0,e=a.length;d<e;){var m=2*(d+1)-1,n=a[m],v=m+1,r=a[v];if(void 0!==n&&0>K(n,c))void 0!==r&&0>K(r,n)?(a[d]=r,a[v]=c,d=v):(a[d]=n,a[m]=c,d=m);else if(void 0!==r&&0>K(r,c))a[d]=r,a[v]=c,d=v;else break a}}return b}return null}function K(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}var N=[],O=[],P=1,Q=null,R=3,S=!1,T=!1,U=!1;
|
|
16
|
+
function V(a){for(var b=L(O);null!==b;){if(null===b.callback)M(O);else if(b.startTime<=a)M(O),b.sortIndex=b.expirationTime,J(N,b);else break;b=L(O)}}function W(a){U=!1;V(a);if(!T)if(null!==L(N))T=!0,f(X);else{var b=L(O);null!==b&&g(W,b.startTime-a)}}
|
|
17
|
+
function X(a,b){T=!1;U&&(U=!1,h());S=!0;var c=R;try{V(b);for(Q=L(N);null!==Q&&(!(Q.expirationTime>b)||a&&!k());){var d=Q.callback;if(null!==d){Q.callback=null;R=Q.priorityLevel;var e=d(Q.expirationTime<=b);b=exports.unstable_now();"function"===typeof e?Q.callback=e:Q===L(N)&&M(N);V(b)}else M(N);Q=L(N)}if(null!==Q)var m=!0;else{var n=L(O);null!==n&&g(W,n.startTime-b);m=!1}return m}finally{Q=null,R=c,S=!1}}
|
|
18
|
+
function Y(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}var Z=l;exports.unstable_ImmediatePriority=1;exports.unstable_UserBlockingPriority=2;exports.unstable_NormalPriority=3;exports.unstable_IdlePriority=5;exports.unstable_LowPriority=4;exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=R;R=a;try{return b()}finally{R=c}};
|
|
19
|
+
exports.unstable_next=function(a){switch(R){case 1:case 2:case 3:var b=3;break;default:b=R}var c=R;R=b;try{return a()}finally{R=c}};
|
|
20
|
+
exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();if("object"===typeof c&&null!==c){var e=c.delay;e="number"===typeof e&&0<e?d+e:d;c="number"===typeof c.timeout?c.timeout:Y(a)}else c=Y(a),e=d;c=e+c;a={id:P++,callback:b,priorityLevel:a,startTime:e,expirationTime:c,sortIndex:-1};e>d?(a.sortIndex=e,J(O,a),null===L(N)&&a===L(O)&&(U?h():U=!0,g(W,e-d))):(a.sortIndex=c,J(N,a),T||S||(T=!0,f(X)));return a};exports.unstable_cancelCallback=function(a){a.callback=null};
|
|
21
|
+
exports.unstable_wrapCallback=function(a){var b=R;return function(){var c=R;R=b;try{return a.apply(this,arguments)}finally{R=c}}};exports.unstable_getCurrentPriorityLevel=function(){return R};exports.unstable_shouldYield=function(){var a=exports.unstable_now();V(a);var b=L(N);return b!==Q&&null!==Q&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime<Q.expirationTime||k()};exports.unstable_requestPaint=Z;exports.unstable_continueExecution=function(){T||S||(T=!0,f(X))};
|
|
22
|
+
exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return L(N)};exports.unstable_Profiling=null;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.
|
|
1
|
+
/** @license React v0.18.0
|
|
2
2
|
* scheduler-unstable_mock.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
var enableSchedulerDebugging = false;
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
var enableProfiling = true;
|
|
22
21
|
|
|
23
22
|
var currentTime = 0;
|
|
@@ -372,47 +371,50 @@ function stopLoggingProfilingEvents() {
|
|
|
372
371
|
eventLogIndex = 0;
|
|
373
372
|
return buffer;
|
|
374
373
|
}
|
|
375
|
-
function markTaskStart(task,
|
|
374
|
+
function markTaskStart(task, ms) {
|
|
376
375
|
if (enableProfiling) {
|
|
377
376
|
profilingState[QUEUE_SIZE]++;
|
|
378
377
|
|
|
379
378
|
if (eventLog !== null) {
|
|
380
|
-
|
|
379
|
+
// performance.now returns a float, representing milliseconds. When the
|
|
380
|
+
// event is logged, it's coerced to an int. Convert to microseconds to
|
|
381
|
+
// maintain extra degrees of precision.
|
|
382
|
+
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
|
|
381
383
|
}
|
|
382
384
|
}
|
|
383
385
|
}
|
|
384
|
-
function markTaskCompleted(task,
|
|
386
|
+
function markTaskCompleted(task, ms) {
|
|
385
387
|
if (enableProfiling) {
|
|
386
388
|
profilingState[PRIORITY] = NoPriority;
|
|
387
389
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
388
390
|
profilingState[QUEUE_SIZE]--;
|
|
389
391
|
|
|
390
392
|
if (eventLog !== null) {
|
|
391
|
-
logEvent([TaskCompleteEvent,
|
|
393
|
+
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
|
|
392
394
|
}
|
|
393
395
|
}
|
|
394
396
|
}
|
|
395
|
-
function markTaskCanceled(task,
|
|
397
|
+
function markTaskCanceled(task, ms) {
|
|
396
398
|
if (enableProfiling) {
|
|
397
399
|
profilingState[QUEUE_SIZE]--;
|
|
398
400
|
|
|
399
401
|
if (eventLog !== null) {
|
|
400
|
-
logEvent([TaskCancelEvent,
|
|
402
|
+
logEvent([TaskCancelEvent, ms * 1000, task.id]);
|
|
401
403
|
}
|
|
402
404
|
}
|
|
403
405
|
}
|
|
404
|
-
function markTaskErrored(task,
|
|
406
|
+
function markTaskErrored(task, ms) {
|
|
405
407
|
if (enableProfiling) {
|
|
406
408
|
profilingState[PRIORITY] = NoPriority;
|
|
407
409
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
408
410
|
profilingState[QUEUE_SIZE]--;
|
|
409
411
|
|
|
410
412
|
if (eventLog !== null) {
|
|
411
|
-
logEvent([TaskErrorEvent,
|
|
413
|
+
logEvent([TaskErrorEvent, ms * 1000, task.id]);
|
|
412
414
|
}
|
|
413
415
|
}
|
|
414
416
|
}
|
|
415
|
-
function markTaskRun(task,
|
|
417
|
+
function markTaskRun(task, ms) {
|
|
416
418
|
if (enableProfiling) {
|
|
417
419
|
runIdCounter++;
|
|
418
420
|
profilingState[PRIORITY] = task.priorityLevel;
|
|
@@ -420,34 +422,34 @@ function markTaskRun(task, time) {
|
|
|
420
422
|
profilingState[CURRENT_RUN_ID] = runIdCounter;
|
|
421
423
|
|
|
422
424
|
if (eventLog !== null) {
|
|
423
|
-
logEvent([TaskRunEvent,
|
|
425
|
+
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
428
|
}
|
|
427
|
-
function markTaskYield(task,
|
|
429
|
+
function markTaskYield(task, ms) {
|
|
428
430
|
if (enableProfiling) {
|
|
429
431
|
profilingState[PRIORITY] = NoPriority;
|
|
430
432
|
profilingState[CURRENT_TASK_ID] = 0;
|
|
431
433
|
profilingState[CURRENT_RUN_ID] = 0;
|
|
432
434
|
|
|
433
435
|
if (eventLog !== null) {
|
|
434
|
-
logEvent([TaskYieldEvent,
|
|
436
|
+
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
|
|
435
437
|
}
|
|
436
438
|
}
|
|
437
439
|
}
|
|
438
|
-
function markSchedulerSuspended(
|
|
440
|
+
function markSchedulerSuspended(ms) {
|
|
439
441
|
if (enableProfiling) {
|
|
440
442
|
mainThreadIdCounter++;
|
|
441
443
|
|
|
442
444
|
if (eventLog !== null) {
|
|
443
|
-
logEvent([SchedulerSuspendEvent,
|
|
445
|
+
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
|
|
444
446
|
}
|
|
445
447
|
}
|
|
446
448
|
}
|
|
447
|
-
function markSchedulerUnsuspended(
|
|
449
|
+
function markSchedulerUnsuspended(ms) {
|
|
448
450
|
if (enableProfiling) {
|
|
449
451
|
if (eventLog !== null) {
|
|
450
|
-
logEvent([SchedulerResumeEvent,
|
|
452
|
+
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
|
|
451
453
|
}
|
|
452
454
|
}
|
|
453
455
|
}
|