Skip to content

Conversation

@HardyNLee
Copy link
Contributor

@HardyNLee HardyNLee commented Jan 20, 2026

介绍

#832 后,在编辑器那边预览的时候,有几率卡死并触发以下错误。

image

cloneDeep一下似乎就好了

@gemini-code-assist
Copy link

Summary of Changes

Hello @HardyNLee, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在解决 #832 引入的一个关键错误,该错误导致编辑器在预览时卡死。核心问题被确定为在转换赋值过程中对源对象进行了意外修改。通过在应用转换之前对源对象进行深度克隆,此拉取请求确保了数据完整性,并防止编辑器进入不稳定状态,从而提高了预览功能的稳定性和可靠性。

Highlights

  • 修复编辑器预览卡死问题: 解决了在 fix: resume alpha filter #832 之后,编辑器预览时可能出现的卡死和错误,通过深度克隆源对象来避免对原始数据进行意外修改。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

你好,这次的 Pull Request 旨在修复一个修改只读 source 对象导致的崩溃问题。通过引入 cloneDeep 来创建 source 对象的可变副本,确实解决了这个 bug。

我的主要反馈是关于性能优化的。虽然 cloneDeep 能解决问题,但它是一个资源密集型操作。在这个特定场景下,由于只修改了对象的顶层属性,使用浅拷贝(例如 { ...source })就足够了,而且效率更高。我已经在代码中提出了具体的修改建议。这个改动可以在保证代码正确性的同时提升性能。

export default class PixiStage {
public static assignTransform<T extends ITransform>(target: T, source?: ITransform, convertAlpha = true) {
if (!source) return;
let cloneSource = cloneDeep(source);

Choose a reason for hiding this comment

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

medium

为了解决只读属性无法修改的问题,这里使用了 cloneDeep,这虽然能解决问题,但 cloneDeep 是一个深拷贝操作,当 source 对象复杂时可能会有性能开销。分析此函数可知,我们仅修改了 source 对象的一级属性(alphaalphaFilterVal),而嵌套的对象(如 scaleposition)仅被读取。因此,使用浅拷贝就足以解决问题,并且性能会好得多。

建议使用对象展开语法 { ...source } 来进行浅拷贝。另外,由于 cloneSource 变量未被重新赋值,建议使用 const 声明。

Suggested change
let cloneSource = cloneDeep(source);
const cloneSource = { ...source };

Copy link
Member

@MakinoharaShoko MakinoharaShoko left a comment

Choose a reason for hiding this comment

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

assignTransform 是一个调用频繁的函数,每一帧都会调用,深拷贝可能影响性能,建议单独取出受影响的字段赋值给临时变量。

@HardyNLee HardyNLee force-pushed the fix/read-only-source branch from 3eee53b to 298dead Compare January 20, 2026 15:19
@HardyNLee
Copy link
Contributor Author

assignTransform 是一个调用频繁的函数,每一帧都会调用,深拷贝可能影响性能,建议单独取出受影响的字段赋值给临时变量。

已修改

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