Feature/editor optimization (#251)
* refactor: 编辑器/运行时架构拆分与构建系统升级 * feat(core): 层级系统重构与UI变换矩阵修复 * refactor: 移除 ecs-components 聚合包并修复跨包组件查找问题 * fix(physics): 修复跨包组件类引用问题 * feat: 统一运行时架构与浏览器运行支持 * feat(asset): 实现浏览器运行时资产加载系统 * fix: 修复文档、CodeQL安全问题和CI类型检查错误 * fix: 修复文档、CodeQL安全问题和CI类型检查错误 * fix: 修复文档、CodeQL安全问题、CI类型检查和测试错误 * test: 补齐核心模块测试用例,修复CI构建配置 * fix: 修复测试用例中的类型错误和断言问题 * fix: 修复 turbo build:npm 任务的依赖顺序问题 * fix: 修复 CI 构建错误并优化构建性能
This commit is contained in:
@@ -21,6 +21,9 @@ import {
|
||||
} from './Serialization/IncrementalSerializer';
|
||||
import { ComponentPoolManager } from './Core/ComponentPool';
|
||||
import { PerformanceMonitor } from '../Utils/PerformanceMonitor';
|
||||
import { ProfilerSDK } from '../Utils/Profiler/ProfilerSDK';
|
||||
import { ProfileCategory } from '../Utils/Profiler/ProfilerTypes';
|
||||
import { AutoProfiler } from '../Utils/Profiler/AutoProfiler';
|
||||
import { ServiceContainer, type ServiceType, type IService } from '../Core/ServiceContainer';
|
||||
import { createInstance, isInjectable, injectProperties } from '../Core/DI';
|
||||
import { createLogger } from '../Utils/Logger';
|
||||
@@ -334,30 +337,58 @@ export class Scene implements IScene {
|
||||
* 更新场景
|
||||
*/
|
||||
public update() {
|
||||
ComponentPoolManager.getInstance().update();
|
||||
// 开始性能采样帧
|
||||
ProfilerSDK.beginFrame();
|
||||
const frameHandle = ProfilerSDK.beginSample('Scene.update', ProfileCategory.ECS);
|
||||
|
||||
this.entities.updateLists();
|
||||
try {
|
||||
ComponentPoolManager.getInstance().update();
|
||||
|
||||
const systems = this.systems;
|
||||
this.entities.updateLists();
|
||||
|
||||
for (const system of systems) {
|
||||
if (system.enabled) {
|
||||
try {
|
||||
system.update();
|
||||
} catch (error) {
|
||||
this._handleSystemError(system, 'update', error);
|
||||
const systems = this.systems;
|
||||
|
||||
// Update 阶段
|
||||
const updateHandle = ProfilerSDK.beginSample('Systems.update', ProfileCategory.ECS);
|
||||
try {
|
||||
for (const system of systems) {
|
||||
if (system.enabled) {
|
||||
const systemHandle = ProfilerSDK.beginSample(system.systemName, ProfileCategory.ECS);
|
||||
try {
|
||||
system.update();
|
||||
} catch (error) {
|
||||
this._handleSystemError(system, 'update', error);
|
||||
} finally {
|
||||
ProfilerSDK.endSample(systemHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
ProfilerSDK.endSample(updateHandle);
|
||||
}
|
||||
}
|
||||
|
||||
for (const system of systems) {
|
||||
if (system.enabled) {
|
||||
try {
|
||||
system.lateUpdate();
|
||||
} catch (error) {
|
||||
this._handleSystemError(system, 'lateUpdate', error);
|
||||
// LateUpdate 阶段
|
||||
const lateUpdateHandle = ProfilerSDK.beginSample('Systems.lateUpdate', ProfileCategory.ECS);
|
||||
try {
|
||||
for (const system of systems) {
|
||||
if (system.enabled) {
|
||||
const systemHandle = ProfilerSDK.beginSample(`${system.systemName}.late`, ProfileCategory.ECS);
|
||||
try {
|
||||
system.lateUpdate();
|
||||
} catch (error) {
|
||||
this._handleSystemError(system, 'lateUpdate', error);
|
||||
} finally {
|
||||
ProfilerSDK.endSample(systemHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
ProfilerSDK.endSample(lateUpdateHandle);
|
||||
}
|
||||
} finally {
|
||||
ProfilerSDK.endSample(frameHandle);
|
||||
// 结束性能采样帧
|
||||
ProfilerSDK.endFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,6 +724,11 @@ export class Scene implements IScene {
|
||||
|
||||
injectProperties(system, this._services);
|
||||
|
||||
// 调试模式下自动包装系统方法以收集性能数据(ProfilerSDK 启用时表示调试模式)
|
||||
if (ProfilerSDK.isEnabled()) {
|
||||
AutoProfiler.wrapInstance(system, system.systemName, ProfileCategory.ECS);
|
||||
}
|
||||
|
||||
system.initialize();
|
||||
|
||||
this.logger.debug(`System ${constructor.name} registered and initialized`);
|
||||
|
||||
Reference in New Issue
Block a user