dev error for excessive pending callbacks

Summary:
We've seen some crashes from exceeding property limits (>200k) from storing callbacks, which is insane since callbacks should be called and cleaned up right away in most cases. Browsing around I never see more than about 50 pending callbacks when firing off a whole much of animations and measures and stuff.

In order to track down the leak, I added some code in `__DEV__` to provide more info - hopefully some developers will hit it and report the issue. Unfortunately it's not easy to get any useful information in prod because we strip all the useful debug info, but if this continues to be a problem we could try capturing that info in prod as well (and maybe other info, too).

Reviewed By: PeteTheHeat

Differential Revision: D16267702

fbshipit-source-id: 8185bb8ff0d646b307c98238616950086b1a608f
This commit is contained in:
Spencer Ahrens
2019-07-17 14:15:54 -07:00
committed by Facebook Github Bot
parent 8dcee62be9
commit 1e45a41dc2
+15
View File
@@ -210,6 +210,21 @@ class MessageQueue {
if (this._callID > DEBUG_INFO_LIMIT) {
delete this._debugInfo[this._callID - DEBUG_INFO_LIMIT];
}
if (this._successCallbacks.size > 500) {
const info = {};
this._successCallbacks.forEach((_, callID) => {
const debug = this._debugInfo[callID];
const module = debug && this._remoteModuleTable[debug[0]];
const method = debug && this._remoteMethodTable[debug[0]][debug[1]];
info[callID] = {module, method};
});
console.error(
`Please report: Excessive number of pending callbacks: ${
this._successCallbacks.size
}. Some pending callbacks that might have leaked by never being called from native code:`,
info,
);
}
}
// Encode callIDs into pairs of callback identifiers by shifting left and using the rightmost bit
// to indicate fail (0) or success (1)