mirror of
https://github.com/status-im/react-native.git
synced 2025-02-18 20:36:41 +00:00
Log timer identifiers in systrace
Reviewed By: davidaurelio Differential Revision: D3819518 fbshipit-source-id: 98e9ed4af93c9c02f4bb8d9152b19556566b81f1
This commit is contained in:
parent
66ce1297c2
commit
a1f31d12fd
Libraries/JavaScriptAppEngine/System/JSTimers
@ -15,6 +15,7 @@
|
|||||||
// in dependencies. NativeModules > BatchedBridge > MessageQueue > JSTimersExecution
|
// in dependencies. NativeModules > BatchedBridge > MessageQueue > JSTimersExecution
|
||||||
const RCTTiming = require('NativeModules').Timing;
|
const RCTTiming = require('NativeModules').Timing;
|
||||||
const JSTimersExecution = require('JSTimersExecution');
|
const JSTimersExecution = require('JSTimersExecution');
|
||||||
|
const parseErrorStack = require('parseErrorStack');
|
||||||
|
|
||||||
// Returns a free index if one is available, and the next consecutive index otherwise.
|
// Returns a free index if one is available, and the next consecutive index otherwise.
|
||||||
function _getFreeIndex(): number {
|
function _getFreeIndex(): number {
|
||||||
@ -31,6 +32,14 @@ function _allocateCallback(func: Function, type: $Keys<typeof JSTimersExecution.
|
|||||||
JSTimersExecution.timerIDs[freeIndex] = id;
|
JSTimersExecution.timerIDs[freeIndex] = id;
|
||||||
JSTimersExecution.callbacks[freeIndex] = func;
|
JSTimersExecution.callbacks[freeIndex] = func;
|
||||||
JSTimersExecution.types[freeIndex] = type;
|
JSTimersExecution.types[freeIndex] = type;
|
||||||
|
if (__DEV__) {
|
||||||
|
const e = (new Error() : any);
|
||||||
|
e.framesToPop = 1;
|
||||||
|
const stack = parseErrorStack(e);
|
||||||
|
if (stack) {
|
||||||
|
JSTimersExecution.identifiers[freeIndex] = stack.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ const JSTimersExecution = {
|
|||||||
timerIDs: [],
|
timerIDs: [],
|
||||||
immediates: [],
|
immediates: [],
|
||||||
requestIdleCallbacks: [],
|
requestIdleCallbacks: [],
|
||||||
|
identifiers: ([] : [{methodName: string}]),
|
||||||
|
|
||||||
errors: (null : ?[Error]),
|
errors: (null : ?[Error]),
|
||||||
|
|
||||||
@ -78,6 +79,11 @@ const JSTimersExecution = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (__DEV__) {
|
||||||
|
const identifier = JSTimersExecution.identifiers[timerIndex] || {};
|
||||||
|
Systrace.beginEvent('Systrace.callTimer: ' + identifier.methodName);
|
||||||
|
}
|
||||||
|
|
||||||
// Clear the metadata
|
// Clear the metadata
|
||||||
if (type === JSTimersExecution.Type.setTimeout ||
|
if (type === JSTimersExecution.Type.setTimeout ||
|
||||||
type === JSTimersExecution.Type.setImmediate ||
|
type === JSTimersExecution.Type.setImmediate ||
|
||||||
@ -113,6 +119,10 @@ const JSTimersExecution = {
|
|||||||
JSTimersExecution.errors.push(e);
|
JSTimersExecution.errors.push(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (__DEV__) {
|
||||||
|
Systrace.endEvent();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,6 +238,7 @@ const JSTimersExecution = {
|
|||||||
JSTimersExecution.timerIDs[i] = null;
|
JSTimersExecution.timerIDs[i] = null;
|
||||||
JSTimersExecution.callbacks[i] = null;
|
JSTimersExecution.callbacks[i] = null;
|
||||||
JSTimersExecution.types[i] = null;
|
JSTimersExecution.types[i] = null;
|
||||||
|
JSTimersExecution.identifiers[i] = null;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user