Skip to content

Merge origin/main into origin/feat/2.5#1034

Merged
yiiqii merged 9 commits into
feat/2.5from
main
Jun 13, 2025
Merged

Merge origin/main into origin/feat/2.5#1034
yiiqii merged 9 commits into
feat/2.5from
main

Conversation

@yiiqii

@yiiqii yiiqii commented Jun 13, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an error in pre composition mask migration.
    • Resolved an issue where videos could be downloaded twice when loaded via the asset manager.
  • Documentation

    • Updated changelogs for version 2.4.7.
    • Improved documentation for font style settings in text components.
  • Chores

    • Updated package versions to 2.4.7 across all related packages.

yiiqii and others added 9 commits June 6, 2025 16:51
Merge origin/main into origin/dev
#1029)

* fix: video will be downloaded twice when loaded using the assetmanager

* chore: modify type

---------

Co-authored-by: yiiqii <yfj5tzl2005@sina.com>
fix: pre composition mask migration error
docs: 修改 setFontStyle 注释
Merge origin/dev into origin/main
@yiiqii
yiiqii requested a review from wumaolinmaoan June 13, 2025 05:50
@coderabbitai

coderabbitai Bot commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update increments package versions to 2.4.7 and updates changelogs with two main fixes: resolving pre composition mask migration errors and preventing duplicate video downloads via the assetManager. Several core files are refactored to simplify asset and texture handling, adjust scene interface structure, and correct migration logic.

Changes

Files/Groups Change Summary
CHANGELOG.md, CHANGELOG-zh_CN.md Added 2.4.7 release notes with two bug fixes.
packages/effects-core/package.json
packages/effects-helper/package.json
packages/effects-threejs/package.json
packages/effects-webgl/package.json
packages/effects/package.json
plugin-packages/alipay-downgrade/package.json
plugin-packages/downgrade/package.json
plugin-packages/editor-gizmo/package.json
plugin-packages/model/package.json
plugin-packages/multimedia/package.json
plugin-packages/orientation-transformer/package.json
plugin-packages/rich-text/package.json
plugin-packages/spine/package.json
plugin-packages/stats/package.json
Incremented version numbers from 2.4.6 to 2.4.7.
packages/effects-core/src/asset-manager.ts Refactored scene loading: simplified asset/image assignment, added explicit textures and assets in scene object.
packages/effects-core/src/asset-service.ts Simplified texture initialization: removed type checks, directly assigns and initializes textures from engine.
packages/effects-core/src/composition.ts Changed texture assignment in constructor; removed conditional clearing of scene textures.
packages/effects-core/src/fallback/migration.ts Simplified v3.2 migration: removed main composition logic, processes all compositions directly.
packages/effects-core/src/plugins/particle/particle-system.ts Added explicit type assertion to originVec for clarity.
packages/effects-core/src/plugins/text/text-item.ts Updated JSDoc for setFontStyle method, clarifying description and default value.
packages/effects-core/src/scene.ts Changed Scene interface: made textures non-optional, added assets property.
packages/effects/src/player.ts Changed asset preparation to use scene.assets instead of assetManager’s assets.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant AssetManager
    participant AssetService
    participant Scene

    Player->>AssetManager: loadScene()
    AssetManager->>Scene: Construct scene object (with textures, images, assets)
    Player->>AssetService: prepareAssets(scene.assets)
    AssetService->>Scene: Initialize textures and assets
Loading

Possibly related PRs

Suggested reviewers

  • wumaolinmaoan

Poem

A hop and a skip, new versions arrive,
With assets and textures now neatly contrived.
No more double videos, nor migration confusion,
The changelog sings clear in every inclusion.
As 2.4.7 leaps through the code,
🐇 This bunny applauds the streamlined load!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (3)
packages/effects-core/src/composition.ts (1)

386-389: 🛠️ Refactor suggestion

Expose a defensive copy from the textures getter

get textures() returns the private _textures array by reference, so external callers can mutate the internal collection and break invariants (e.g. undefined holes leading to NPEs in updateVideo, offloadTexture, etc.).

Two quick-win fixes:

-get textures () {
-  return this._textures;
-}
+get textures () {
+  // return a read-only view
+  return [...this._textures];
+}

or

get textures () {
  return Object.freeze(this._textures.slice());
}
packages/effects/src/player.ts (1)

343-349: 💡 Verification agent

🧩 Analysis chain

Double-check all call-sites after prepareAssets signature change

prepareAssets(scene, scene.assets) looks correct with the new Scene.assets field.
Make sure no stale invocations still pass an AssetManager#getAssets() result; otherwise those sites will now silently miss assets.


🏁 Script executed:

#!/bin/bash
# Find other call-sites that may still pass two arguments where the second
# one is NOT 'scene.assets'.
rg --line-number --context 2 $'prepareAssets\\([^,]+,' | grep -v 'scene\\.assets'

Length of output: 1145


Update stale prepareAssets invocation in three-display-object.ts

A grep run shows one remaining call-site still passing assetManager.getAssets() instead of scene.assets:

• packages/effects-threejs/src/three-display-object.ts:101

Suggested diff:

- this.assetService.prepareAssets(scene, assetManager.getAssets());
+ this.assetService.prepareAssets(scene, scene.assets);

Please make this change (and verify no other call-sites remain) to align with the updated prepareAssets(scene, scene.assets) signature.

packages/effects-core/src/asset-manager.ts (1)

158-170: ⚠️ Potential issue

Scene object built without mandatory data in the JSON-object branch

You correctly add textures, images, and assets in the non-JSON branch, but when rawJSON is already a Scene-like object (Scene.isJSONObject(rawJSON) path at line 141) you still return:

scene = { ...rawJSON };

That object may not contain the newly-required properties textures and assets, making later calls (scene.assets in player, assetService.initializeTexture(scene)) crash or misbehave.

Minimal patch: extend both branches consistently.

-          ...rawJSON,
+          ...rawJSON,
+          textures: rawJSON.textures ?? [],
+          assets: this.assets,

(If rawJSON already has those keys they will be preserved.)

Without this, the type system is satisfied (thanks to any in external JSON), but runtime fails.

Please add unit tests that load a bare JSON scene to catch this regression.

🧹 Nitpick comments (3)
packages/effects-core/src/plugins/particle/particle-system.ts (2)

441-441: Explicit vec3 assertion is clear; hoist default vector.
Casting [0, 0, 0] as vec3 improves type safety. Consider moving the originVec declaration above the outer burst loop to prevent recreating this constant on every iteration.


462-462: Simplify translate call with spread; validate fallback.
Using p.transform.translate(...burstOffset) removes redundant type assertions. Ensure burstOffset is always a three-element array to avoid runtime errors—consider an explicit check or default guard.

packages/effects-core/src/composition.ts (1)

300-308: Avoid sharing scene.textures by reference

this._textures now directly points to the same array held by the Scene instance.
If downstream code mutates this._textures (splice, push, = [], …), the original Scene object – potentially shared with other consumers – will be affected, which is error-prone and hard to debug.

Consider cloning or freezing the array at construction time:

-this._textures = scene.textures;
+this._textures = [...scene.textures]; // shallow copy – keeps element identities

At the very least, add a short comment clarifying the intentional aliasing.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 582ebbe and 7a7890e.

📒 Files selected for processing (24)
  • CHANGELOG-zh_CN.md (1 hunks)
  • CHANGELOG.md (1 hunks)
  • packages/effects-core/package.json (1 hunks)
  • packages/effects-core/src/asset-manager.ts (1 hunks)
  • packages/effects-core/src/asset-service.ts (2 hunks)
  • packages/effects-core/src/composition.ts (1 hunks)
  • packages/effects-core/src/fallback/migration.ts (1 hunks)
  • packages/effects-core/src/plugins/particle/particle-system.ts (2 hunks)
  • packages/effects-core/src/plugins/text/text-item.ts (1 hunks)
  • packages/effects-core/src/scene.ts (1 hunks)
  • packages/effects-helper/package.json (1 hunks)
  • packages/effects-threejs/package.json (1 hunks)
  • packages/effects-webgl/package.json (1 hunks)
  • packages/effects/package.json (1 hunks)
  • packages/effects/src/player.ts (1 hunks)
  • plugin-packages/alipay-downgrade/package.json (1 hunks)
  • plugin-packages/downgrade/package.json (1 hunks)
  • plugin-packages/editor-gizmo/package.json (1 hunks)
  • plugin-packages/model/package.json (1 hunks)
  • plugin-packages/multimedia/package.json (1 hunks)
  • plugin-packages/orientation-transformer/package.json (1 hunks)
  • plugin-packages/rich-text/package.json (1 hunks)
  • plugin-packages/spine/package.json (1 hunks)
  • plugin-packages/stats/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (17)
plugin-packages/rich-text/package.json (1)

3-3: Approve version bump to 2.4.7. This aligns with the overall 2.4.7 release and associated fixes.

plugin-packages/model/package.json (1)

3-3: Confirm version bump consistency.
The version field was updated to 2.4.7. Please ensure this aligns with the CHANGELOG entries, release scripts, and all other related package.json files in this release train. Also verify that any lockfiles have been regenerated to reflect this change.

packages/effects-webgl/package.json (1)

3-3: Version bump to 2.4.7 is correct
This aligns with the coordinated patch release across all Effects packages and no other metadata was altered.

packages/effects-threejs/package.json (1)

3-3: Version bump to 2.4.7 is correct
Consistent with the overall release, and no unintended changes to scripts or dependencies.

plugin-packages/multimedia/package.json (1)

3-3: Version bump to 2.4.7 is correct
Matches the coordinated update for the multimedia plugin; no additional edits detected.

packages/effects-helper/package.json (1)

3-3: Version bump to 2.4.7 is correct
Aligned with the patch release and retains all prior configuration.

plugin-packages/stats/package.json (1)

3-3: Version bump to 2.4.7 is correct
Consistent with the release and no other changes present.

plugin-packages/orientation-transformer/package.json (1)

3-3: Approve version bump to 2.4.7
The version update aligns with the coordinated 2.4.7 release across plugins.

plugin-packages/editor-gizmo/package.json (1)

3-3: Approve version bump to 2.4.7
Consistent with the overall release version for editor-gizmo.

plugin-packages/downgrade/package.json (1)

3-3: Approve version bump to 2.4.7
Matches the release version used across downgrade plugins.

plugin-packages/alipay-downgrade/package.json (1)

3-3: Approve version bump to 2.4.7
Version increment is in line with the global 2.4.7 release.

plugin-packages/spine/package.json (1)

3-3: Approve version bump to 2.4.7
Spine plugin now matches the 2.4.7 release across the ecosystem.

packages/effects-core/package.json (1)

3-3: Package version bumped to 2.4.7.
The version update aligns with the new patch release. Confirm that build artifacts, tags, and published packages reflect this version.

packages/effects/package.json (1)

3-3: Package version updated to 2.4.7.
This bump matches the core package and CHANGELOG. Ensure inter-package dependencies and workspace references align with this version.

CHANGELOG.md (1)

10-15: Patch release 2.4.7 entry is accurate.
The new header, date, and fix items correspond to PRs #1030 and #1029. Formatting and ordering are consistent with previous releases.

packages/effects-core/src/plugins/text/text-item.ts (1)

225-228: Doc tweak LGTM

The JSDoc wording and @default tag improve clarity without changing behaviour.

CHANGELOG-zh_CN.md (1)

11-17: Changelog entry for 2.4.7 is well formatted and consistent.
The version header, release date, and fix descriptions align with existing entries and reference the correct PRs.

Comment on lines 20 to 24
textureOptions: Record<string, any>[],
textures: Texture[],
images: ImageLike[],
assets: Record<string, ImageLike>,
consumed?: boolean,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

textureOptions vs. textures – stale field?

With textures promoted to a mandatory array, the purpose of the still-present textureOptions: Record<string, any>[] is unclear and now overlaps semantically.
Keeping both fields invites confusion and accidental misuse.

If legacy code still needs textureOptions, mark it as @deprecated and plan removal; otherwise delete it altogether.

🤖 Prompt for AI Agents
In packages/effects-core/src/scene.ts around lines 20 to 24, the textureOptions
field overlaps with the mandatory textures array and causes confusion. Determine
if textureOptions is still used by legacy code; if yes, mark it as @deprecated
with a comment indicating planned removal. If not used, remove the
textureOptions field entirely to avoid redundancy and potential misuse.

Comment on lines 86 to 90
initializeTexture (scene: Scene) {
for (let i = 0; i < scene.textureOptions.length; i++) {
let textureOptions = scene.textureOptions[i];

if (textureOptions instanceof Texture) {
this.engine.addInstance(textureOptions);
} else {
textureOptions = this.engine.findObject<Texture>({ id:scene.textureOptions[i].id });
scene.textureOptions[i] = textureOptions;
}
textureOptions.initialize();
scene.textures[i] = this.engine.findObject<Texture>({ id: scene.textureOptions[i].id });
scene.textures[i].initialize();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Null-safety missing when resolving textures

engine.findObject<Texture> can legitimately return undefined (e.g., corrupted JSON or missing preload).
Dereferencing the result immediately (scene.textures[i].initialize()) will throw and halt scene loading.

-scene.textures[i] = this.engine.findObject<Texture>({ id: scene.textureOptions[i].id });
-scene.textures[i].initialize();
+const tex = this.engine.findObject<Texture>({ id: scene.textureOptions[i].id });
+if (!tex) {
+  // Keep the index in sync to avoid later mis-alignment.
+  logger.warn(`Texture ${scene.textureOptions[i].id} not found – skipped initialisation`);
+  continue;
+}
+scene.textures[i] = tex;
+tex.initialize();

Also consider switching to a for…of loop to avoid repeated index look-ups.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
initializeTexture (scene: Scene) {
for (let i = 0; i < scene.textureOptions.length; i++) {
let textureOptions = scene.textureOptions[i];
if (textureOptions instanceof Texture) {
this.engine.addInstance(textureOptions);
} else {
textureOptions = this.engine.findObject<Texture>({ id:scene.textureOptions[i].id });
scene.textureOptions[i] = textureOptions;
}
textureOptions.initialize();
scene.textures[i] = this.engine.findObject<Texture>({ id: scene.textureOptions[i].id });
scene.textures[i].initialize();
}
initializeTexture (scene: Scene) {
for (let i = 0; i < scene.textureOptions.length; i++) {
const tex = this.engine.findObject<Texture>({ id: scene.textureOptions[i].id });
if (!tex) {
// Keep the index in sync to avoid later mis-alignment.
logger.warn(`Texture ${scene.textureOptions[i].id} not found – skipped initialisation`);
continue;
}
scene.textures[i] = tex;
tex.initialize();
}
}
🤖 Prompt for AI Agents
In packages/effects-core/src/asset-service.ts around lines 86 to 90, the code
calls initialize() on the result of engine.findObject<Texture> without checking
if it is undefined, which can cause runtime errors. To fix this, add a null
check after calling findObject to ensure the texture exists before calling
initialize. Also, refactor the loop to use a for…of loop over
scene.textureOptions to avoid repeated index look-ups and improve readability.

Comment on lines +119 to 122
for (const comp of compositions) {
processContent(comp);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Mask migration may bleed across compositions

processContent relies on the module-level variable currentMaskComponent.
Iterating over all compositions in a flat loop without resetting that variable means a MASK defined in composition A could erroneously influence OBSCURED items in composition B.

+  for (const comp of compositions) {
+    currentMaskComponent = undefined as unknown as string; // reset per comp
     processContent(comp);
   }

Alternatively, move currentMaskComponent inside processContent.

Please verify with a multi-composition test scene containing independent mask groups.


🏁 Script executed:

#!/bin/bash
# Find declaration and usage of currentMaskComponent
rg -n "currentMaskComponent" packages/effects-core/src/fallback/migration.ts

# Locate processContent definition and calls
rg -n "function processContent" packages/effects-core/src/fallback/migration.ts
rg -n "processContent(" packages/effects-core/src/fallback/migration.ts

Length of output: 512


🏁 Script executed:

#!/bin/bash
# Display context around currentMaskComponent declaration
sed -n '1,80p' packages/effects-core/src/fallback/migration.ts

# Display processContent implementation
sed -n '180,300p' packages/effects-core/src/fallback/migration.ts

# Locate the loop invoking processContent
rg -nF "for (const comp" -n packages/effects-core/src/fallback/migration.ts

Length of output: 6297


Reset mask state per composition
The module‐level currentMaskComponent persists across calls to processContent, so a MASK in one composition can leak into OBSCURED items of the next.

Locations to update:

  • packages/effects-core/src/fallback/migration.ts (around lines 119–122)
     for (const comp of compositions) {
    +  currentMaskComponent = undefined as unknown as string; // reset mask state per comp
       processContent(comp);
     }

Alternatively, declare currentMaskComponent inside processContent to scope it per composition.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
for (const comp of compositions) {
processContent(comp);
}
for (const comp of compositions) {
currentMaskComponent = undefined as unknown as string; // reset mask state per comp
processContent(comp);
}
🤖 Prompt for AI Agents
In packages/effects-core/src/fallback/migration.ts around lines 119 to 122, the
module-level variable currentMaskComponent is not reset between iterations over
compositions, causing mask state to bleed across compositions. To fix this,
either reset currentMaskComponent to null or its initial state at the start of
each loop iteration before calling processContent, or move the declaration of
currentMaskComponent inside the processContent function so it is scoped per
composition and does not persist across calls.

@yiiqii
yiiqii merged commit e96fe10 into feat/2.5 Jun 13, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants