Skip to content

Comments

#242 stageのaddChildの仕様を変更、webgpuのe2eテストのpngを更新#249

Merged
ienaga merged 1 commit intomainfrom
develop
Feb 11, 2026
Merged

#242 stageのaddChildの仕様を変更、webgpuのe2eテストのpngを更新#249
ienaga merged 1 commit intomainfrom
develop

Conversation

@ienaga
Copy link
Member

@ienaga ienaga commented Feb 11, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 11, 2026 00:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Stage の addChild における root 管理仕様を調整し、WebGPU の描画結果変更に伴う e2e スナップショット更新と、publish workflow の npm publish オプション調整を行うPRです。

Changes:

  • Stage の addChild$rootMap を一時的に操作し、root 解決ロジックを変更
  • WebGPU の instanced fragment shader を textureSampleLevel(..., 0) から textureSample(...) に変更
  • WebGPU e2e スナップショット PNG 更新、および publish workflow の npm publish を --access public 付きに変更

Reviewed changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 2 comments.

File Description
packages/webgpu/src/Shader/wgsl/fragment/InstancedFragment.ts インスタンス描画のテクスチャサンプリング方法を変更
packages/display/src/Stage.ts Stage 直下に追加された DisplayObject の root 管理方法を変更
e2e/snapshots/webgpu/shape.spec.ts-snapshots/load-image-flip-webgpu-darwin.png WebGPU 描画結果変更に伴うスナップショット更新
.github/workflows/publish.yml publish 時の権限追加と npm publish --access public を適用
Comments suppressed due to low confidence (2)

packages/display/src/Stage.ts:195

  • Stage overrides addChild() but not addChildAt(). Calling stage.addChildAt() will go through DisplayObjectContainerAddChildUseCase, which sets $rootMap to stage.root (currently null unless Stage is in $rootMap), so children added via addChildAt can end up with a null root while addChild sets root to self. Consider overriding addChildAt() (or refactoring shared logic) to keep Stage root assignment consistent.
    addChild<T extends DisplayObject>(display_object: T): T
    {
        $stageAssignedMap.add(display_object.instanceId);

        // fixed logic
        $rootMap.set(this, display_object);
        super.addChild(display_object);

        // fixed logic for root map
        $rootMap.delete(this);
        $rootMap.set(display_object, display_object);

        return display_object;
    }

packages/display/src/Stage.ts:195

  • This change alters Stage’s root-assignment behavior in a non-trivial way (temporary $rootMap mutation + cleanup). There are existing unit tests for Stage but none cover addChild()/root behavior; please add tests that assert (1) a child added to Stage has child.root === child, (2) Stage does not retain a $rootMap entry after adding, and (3) addChildAt() behaves consistently.
    addChild<T extends DisplayObject>(display_object: T): T
    {
        $stageAssignedMap.add(display_object.instanceId);

        // fixed logic
        $rootMap.set(this, display_object);
        super.addChild(display_object);

        // fixed logic for root map
        $rootMap.delete(this);
        $rootMap.set(display_object, display_object);

        return display_object;
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 184 to 193
$stageAssignedMap.add(display_object.instanceId);

// fixed logic
$rootMap.set(this, display_object);
super.addChild(display_object);

// fixed logic for root map
$rootMap.delete(this);
$rootMap.set(display_object, display_object);

Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$rootMap.set(this, display_object) is used as a temporary hack so super.addChild() will treat display_object as the Stage root. However super.addChild() dispatches events (e.g. ADDED) that can throw, which would skip the cleanup and leave this mapped in $rootMap (and also leave display_object.instanceId in $stageAssignedMap). Wrap the super.addChild() call in try/finally to guarantee $rootMap.delete(this) (and rollback stage assignment if the add fails).

Suggested change
$stageAssignedMap.add(display_object.instanceId);
// fixed logic
$rootMap.set(this, display_object);
super.addChild(display_object);
// fixed logic for root map
$rootMap.delete(this);
$rootMap.set(display_object, display_object);
const instanceId = display_object.instanceId;
$stageAssignedMap.add(instanceId);
// fixed logic
$rootMap.set(this, display_object);
let added = false;
try {
super.addChild(display_object);
added = true;
} finally {
// always remove temporary root mapping
$rootMap.delete(this);
// rollback stage assignment if addChild fails
if (!added) {
$stageAssignedMap.delete(instanceId);
}
}
if (added) {
// fixed logic for root map
$rootMap.set(display_object, display_object);
}

Copilot uses AI. Check for mistakes.
Comment on lines +186 to 190
// fixed logic
$rootMap.set(this, display_object);
super.addChild(display_object);

// fixed logic for root map
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments // fixed logic / // fixed logic for root map don’t explain the invariant being maintained here. Please replace them with a short explanation of why Stage is temporarily inserted into $rootMap and why it must be removed immediately after super.addChild().

Suggested change
// fixed logic
$rootMap.set(this, display_object);
super.addChild(display_object);
// fixed logic for root map
// Temporarily register Stage as the current root so that any logic in super.addChild()
// that consults $rootMap can treat this added subtree as belonging to this Stage.
$rootMap.set(this, display_object);
super.addChild(display_object);
// Restore the $rootMap invariant: only root DisplayObjects (Stage children) are kept as keys,
// not Stage itself, so remove the temporary Stage entry and register the new root child instead.

Copilot uses AI. Check for mistakes.
@ienaga ienaga merged commit c228273 into main Feb 11, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant