-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev performance reduced by add_owner_to_object
calls when using a $state.raw
and a context created by a function
#15072
Comments
The problem with this is that Possible solutions:
|
There's another (I think more serious) side-effect of the current If you call Otherwise, I believe the |
Here is a minimal REPL showing the problem with calling Incrementing |
Instead of doing ownership addition at each `getContext` call site, we do it once as the `setContext` call site and make the state basically global. - avoids potential false positives in edge cases - makes the whole thing more performant, especially around things like calling `getContext` inside a list item component - false negatives are unlikely from this fixes #15072
Describe the bug
This issue happens in the development mode only. I believe this bug is somewhat related to #14491, respectively to the fix #14533, which helps with this case for classes, but not functions.
Steps to reproduce:
$state.raw
field (e.g. by using a factory function)$state.raw
with something sufficiently deepgetContext
to retrieve the context (same symptom as in the referenced PR)Reproduction
https://svelte.dev/playground/ab1f18a235f44df28eae50837df5bc1d?version=5.19.0
The Svelte REPL apparently cannot build the component in a dev mode, therefore you need to run it in localhost. What I see in the devtool performance monitor is something like this:
Looking at the
getContext
implementation, it is understandable why this happens. Theadd_owner_to_object
simply recurses into the fields of the state. I hope this could be addressed so that people who don't use classes (for whatever reason) aren't surprised by this.Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: