diff --git a/plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html b/plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html index ec63e7c41..383ea5a3c 100644 --- a/plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html +++ b/plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html @@ -1249,7 +1249,23 @@ this._addDataResponseSize(data.length); } startUpdateModel = performance.now(); - this._updateModel(data, replaceModel); + const jsonData = JSON.parse(data); + if (!this._model /* first load */) { + let traceViewerTraceModelSettings = JSON.parse(localStorage.getItem('trace-viewertrace_model_settings')) || {"value": {}}; + for(const traceEvent of jsonData['traceEvents']) { + if (traceEvent['name'] !== undefined && traceEvent['name'] == 'process_name') { + // Collapse the process if it has more than 20 threads. + if (traceEvent['thread_count'] !== undefined && traceEvent['thread_count'] > 20) { + // Collapse the process only if preference is not set. + if (traceViewerTraceModelSettings['value']["processes."+traceEvent['args']['name']] === undefined) { + traceViewerTraceModelSettings['value']["processes."+traceEvent['args']['name']] = {'expanded': false}; + } + } + } + } + localStorage.setItem('trace-viewertrace_model_settings', JSON.stringify(traceViewerTraceModelSettings)); + } + this._updateModel(jsonData, replaceModel); if (!this._isOss) { this._addUpdateModelLatency(performance.now() - startUpdateModel); } @@ -1346,7 +1362,6 @@ // the new data is merged with the old data. // Returns a void promise. _updateModel: function(data, replaceModel) { - data = JSON.parse(data); if (!this._model /* first load */ || replaceModel) { // Only give no events alert for first load or replace load if (!data['returnedEventsSize']) {