Internal Component._setActive can be accidentally overridden by user Script
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 54/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
- 技術スタック
- typescript
- 領域
- backend
調査の方向性
Read packages/core/src/Component.ts and packages/core/src/Entity.ts, especially the lifecycle call sites linked in the issue; then find the core regression-test conventions. Add a focused test for a Script with a string-keyed _setActive helper, covering component and hierarchy activation plus onAwake and onEnable. Done means the helper is not invoked by Engine lifecycle calls, while the virtual hooks still work and public declarations remain unchanged.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
A user Script can accidentally override the Engine's internal Component._setActive(value, activeChangeFlag) method with an unrelated helper of the same name. Entity currently invokes the method through normal JavaScript dynamic dispatch, so the user method receives Engine lifecycle arguments and can crash project startup.
This has occurred twice in independent scripts on @galacean/[email protected] (GameManager and UIController).
To Reproduce
import { Entity, Script } from "@galacean/engine";
export default class UIController extends Script {
private _setActive(entity: Entity | null, active: boolean): void {
if (entity) entity.isActive = active;
}
}
entity.addComponent(UIController);
Entity.addComponent() calls:
component._setActive(true, ActiveChangeFlag.All);
Because TypeScript private is emitted as a normal string-keyed prototype method, the call dispatches to UIController._setActive. The boolean true is then treated as an Entity, producing:
TypeError: Cannot create property 'isActive' on boolean 'true'
at UIController._setActive
at Entity.addComponent
Current source locations:
Why TypeScript does not catch it
_setActive is marked @internal, and packages/core/tsconfig.json enables stripInternal. The published Component.d.ts therefore contains no _setActive member, so strict consumer typechecking sees the user helper as a new private method rather than an override.
Expected behavior
Internal non-virtual lifecycle operations must not be overrideable by consumer Script members. A user helper named _setActive should not corrupt component activation, while intentionally virtual Engine hooks such as _onAwake and _onEnable must keep their existing behavior.
Suggested ownership boundary
Give this non-virtual operation a package-internal unique Symbol identity and let Entity call it through that identity. The symbol can be imported directly between core modules without being re-exported from packages/core/src/index.ts; @internal + stripInternal can keep the public declarations unchanged. This encodes non-overridability once and does not reserve the string _setActive in user scripts.
A focused regression should add a Script with an unrelated string-keyed _setActive helper, then verify that addComponent, hierarchy activation, onAwake, and onEnable still work and the user helper is not invoked by the Engine.
Environment
- Engine:
2.0.0-alpha.43 - Branch/source checked:
dev/2.0@490d2bc8ca1f1c187a995da3c913e59c56959a30 - Browser: Chromium-based runtime
- OS-specific: No
Screenshots
N/A — the failure occurs before window.engine is created.
- 主要言語
- TypeScript
- スター
- 5.9k
- フォーク
- 413
- 平均マージ
- 16時間 17分
- マージ済み PR(30日)
- 41
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
galacean/engine のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
メンテナーはふだん 1 日以内に返信
-
RFC: Adopt Unity-style Collider components and hierarchical Rigidbody ownership対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
メンテナーはふだん 1 日以内に返信
-
SkinnedMeshRenderer should derive default rootBone-space localBounds from mesh and skin対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンenhancement
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
メンテナーはふだん 1 日以内に返信
galacean/engine の issue をすべて見る
似ている issue
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
elastic/kibana#306401 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
agentes-chat/agentes-chat#927 ·
メンテナーはふだん 1 日以内に返信
-
comp/desktop P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#157702 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
e2e-failure ready-to-code
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
redhat-developer/rhdh-plugin-export-overlays#4794 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信