Skip to content

Commit 060fabe

Browse files
committed
Fix: profiling crashes facebook#30661 facebook#28838
1 parent d4688df commit 060fabe

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

packages/react-devtools-shared/src/devtools/ProfilerStore.js

+26-24
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ export default class ProfilerStore extends EventEmitter<{
289289
};
290290

291291
onProfilingStatus: (isProfiling: boolean) => void = isProfiling => {
292+
if (this._isProfiling === isProfiling) {
293+
return;
294+
}
295+
292296
if (isProfiling) {
293297
this._dataBackends.splice(0);
294298
this._dataFrontend = null;
@@ -315,36 +319,34 @@ export default class ProfilerStore extends EventEmitter<{
315319
});
316320
}
317321

318-
if (this._isProfiling !== isProfiling) {
319-
this._isProfiling = isProfiling;
322+
this._isProfiling = isProfiling;
320323

321-
// Invalidate suspense cache if profiling data is being (re-)recorded.
322-
// Note that we clear again, in case any views read from the cache while profiling.
323-
// (That would have resolved a now-stale value without any profiling data.)
324-
this._cache.invalidate();
324+
// Invalidate suspense cache if profiling data is being (re-)recorded.
325+
// Note that we clear again, in case any views read from the cache while profiling.
326+
// (That would have resolved a now-stale value without any profiling data.)
327+
this._cache.invalidate();
325328

326-
this.emit('isProfiling');
329+
this.emit('isProfiling');
327330

328-
// If we've just finished a profiling session, we need to fetch data stored in each renderer interface
329-
// and re-assemble it on the front-end into a format (ProfilingDataFrontend) that can power the Profiler UI.
330-
// During this time, DevTools UI should probably not be interactive.
331-
if (!isProfiling) {
332-
this._dataBackends.splice(0);
333-
this._rendererQueue.clear();
331+
// If we've just finished a profiling session, we need to fetch data stored in each renderer interface
332+
// and re-assemble it on the front-end into a format (ProfilingDataFrontend) that can power the Profiler UI.
333+
// During this time, DevTools UI should probably not be interactive.
334+
if (!isProfiling) {
335+
this._dataBackends.splice(0);
336+
this._rendererQueue.clear();
334337

335-
// Only request data from renderers that actually logged it.
336-
// This avoids unnecessary bridge requests and also avoids edge case mixed renderer bugs.
337-
// (e.g. when v15 and v16 are both present)
338-
this._rendererIDsThatReportedProfilingData.forEach(rendererID => {
339-
if (!this._rendererQueue.has(rendererID)) {
340-
this._rendererQueue.add(rendererID);
338+
// Only request data from renderers that actually logged it.
339+
// This avoids unnecessary bridge requests and also avoids edge case mixed renderer bugs.
340+
// (e.g. when v15 and v16 are both present)
341+
this._rendererIDsThatReportedProfilingData.forEach(rendererID => {
342+
if (!this._rendererQueue.has(rendererID)) {
343+
this._rendererQueue.add(rendererID);
341344

342-
this._bridge.send('getProfilingData', {rendererID});
343-
}
344-
});
345+
this._bridge.send('getProfilingData', {rendererID});
346+
}
347+
});
345348

346-
this.emit('isProcessingData');
347-
}
349+
this.emit('isProcessingData');
348350
}
349351
};
350352
}

0 commit comments

Comments
 (0)