-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
Describe the bug
We've recently begun working on a Svelte 5 compatible next
branch in the Threlte repo. Upgrading from next.95 to next.97 causes a large performance regression in dev mode.
While devtools spelunking I found one suspect - and this was a bit of a wild guess: it appears that in dev mode every getContext()
call triggers a traversal of all object properties of the context. In Threlte apps getContext
can be called quite often, and these contexts contain Three.js objects, which contain many properties, some of which trigger side effects on get
calls. For example, it triggers a console.warn on this property:
I'm not sure the exact penalty here, and I couldn't find evidence that traverse_for_owners
was eating up a lot of CPU, so this could be an unrelated issue / red herring, although I could tell performance was being affected by this warn logging many times for even a simple example.
Here is a comparison of some quick screenshots of profiling next.95 and then next.97 from scene init to first complete render of the positional audio example in our docs:


I haven't done any profiling but the production version of next.97 doesn't seem to have this issue (a production preview of the docs upgraded to next.97 can be found here and the upgrade PR here if relevant)
Happy to follow up any questions and help!
Reproduction
- Clone Threlte and go to the
next
branch. - upgrade svelte to next.97 in apps/docs/package.json
pnpm i && cd apps/docs && pnpm dev
. This will start the docs site locally.- Navigate to any
extras
example and monitor performance.
Logs
No response
System Info
System:
OS: macOS 14.3.1
CPU: (8) arm64 Apple M2
Memory: 134.78 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.0 - /usr/local/bin/node
npm: 10.2.4 - /usr/local/bin/npm
pnpm: 8.15.1 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 123.0.6312.124
Safari: 17.3.1
Severity
blocking an upgrade