Skip to content

Expose Application destroy options - #640

Merged
trezy merged 6 commits into
pixijs:mainfrom
zenblender:destroy-props
Jan 4, 2026
Merged

Expose Application destroy options#640
trezy merged 6 commits into
pixijs:mainfrom
zenblender:destroy-props

Conversation

@zenblender

Copy link
Copy Markdown
Contributor

I discovered various issues that arise from rendering multiple Pixi.js applications on a page at once. When one application is unmounted, it can cause issues for other existing application instances on the page -- graphics may randomly disappear and reappear or render incorrectly.

My assumption is that the default destroy behavior is affecting shared resources in a way that's unintended and causes instability.

This PR adds new destroyOptions and rendererDestroyOptions props on <Application> that are stored until the component is unmounted. At that point, these options will be passed to the application's destroy() method. Ultimately, it allows consumers of pixi/react to better control the lifecycle and destroy behavior of their applications and hopefully avoid these kinds of issues.

See also: #639

@pkg-pr-new

pkg-pr-new Bot commented Jan 2, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/pixijs/pixi-react/@pixi/react@640

commit: 5d5fda1

@trezy
trezy requested review from thejustinwalsh and trezy January 2, 2026 04:00

@trezy trezy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is great work! Very close to being ready to merge.

My one concern is that you hijacked existing tests that didn't have any destroy options set. Please make sure to maintain the original tests, while adding new tests to verify that the destroy options are passed appropriately when set.

It would also be good to test the destroy options independently (I.e. does destroyOptions get passed if rendererDestroyOptions isn't set).

@zenblender

Copy link
Copy Markdown
Contributor Author

Thanks @trezy!

My one concern is that you hijacked existing tests that didn't have any destroy options set. Please make sure to maintain the original tests, while adding new tests to verify that the destroy options are passed appropriately when set.

Thanks, can you clarify further about this? The existing test has the same input that it did prior to this PR (no options passed) but I did add assertions to make sure it results in no value set on root.applicationState.destroyOptions or root.applicationState.rendererDestroyOptions. It basically just adds a sanity check here, so I'm not sure what's being hijacked here. I reverted the description for the test, if this helps? 9de5a89

It would also be good to test the destroy options independently (I.e. does destroyOptions get passed if rendererDestroyOptions isn't set).

Are you referring to the e2e tests for this? I did add tests in createRoot.test.ts that ensure that destroyOptions gets passed if rendererDestroyOptions isn't set.

@zenblender

Copy link
Copy Markdown
Contributor Author

@trezy Oh I see, all of your comments are about the e2e tests...

@zenblender

Copy link
Copy Markdown
Contributor Author

How's this @trezy? 5d5fda1
Thanks!

@zenblender
zenblender requested a review from trezy January 3, 2026 03:34

@trezy trezy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me!

@trezy
trezy added this pull request to the merge queue Jan 4, 2026
@zenblender

Copy link
Copy Markdown
Contributor Author

Thanks @trezy! 🎉

Merged via the queue into pixijs:main with commit 30cf1f8 Jan 4, 2026
8 checks passed
@zenblender

Copy link
Copy Markdown
Contributor Author

Hey @trezy how do we make a release for my changes here? Should I have used a prefix tag on the commit message to trigger a release? Sorry if I overlooked that requirement.

@sergioisidoro

sergioisidoro commented Apr 15, 2026

Copy link
Copy Markdown

I'm currently patching pixi react with these changes. Is there a planned release, or perhaps as an alpha tag ?

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.

3 participants