-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[addon-knobs] addon forces story to be recreated on every knob change #4098
Comments
Has anybody some thoughts about that issue? |
Yeah I understand that's the assumptions, I'm interested in supporting it. @igor-dv would you have an idea how to change this? |
There is the same problem (also an issue) with vue. Knobs became a framework agnostic, and probably it doesn't play well with angular/vue life-cycles. Maybe we need to return back the CC @Hypnosphi |
I think it can still be solved on |
Do you have any specific changes in mind? |
@igor-dv I think @Hypnosphi is unto something. I don't have a clear idea what the code would look like. |
Is there any chance to have that fixed in near future? |
It's extremely annoying especially when using knob with slider |
I just tried using Storybook v5 in an Angular project and the performance with knobs is so atrocious I'm reconsidering using it at all. 2 - 3 second pauses for every keypress I type something into a knobs text field. The knobs addon is not "framework agnostic" if its design is fundamentally incompatible, performance-wise, with Angular and Vue. How did a patch with such a massive, massive performance regression even land? Needless to say, I'm very disappointed, and wondering why I wasted time trying to improve the Angular side of Storybook in the past. If Storybook isn't intended for use with anything other than React, then those other frameworks should be removed from the website and docs so as to not keep misleading people. |
Hey @jonrimmer, looks like there is a lot of talk about this performance issue, especially when using angular. I have a PR open that should help increase performance here: #5811 @shilman , could we take a look at merging this in. It hasn't received any feedback yet but follows what @tmeasday and I were solutioning here: #4740 (comment) |
@CodeByAlex Yeah I saw that. Debouncing should help disguise the problem somewhat, but the fundamental problem would remain: Angular is not a framework where you just re-render the entire component tree whenever something changes. This an approach that is 100% perfect for React, and 0% perfect for anything that does not work in the same way. Knobs should never have been rewritten to work like this, and it absolutely baffles me that it was. So long as this broken approach is kept, issues like this will keep popping up. Nothing has changed since @igor-dv's comment 5 months ago. Knobs cannot work in a framework agnostic way. It needs to understand how the lifecycle / change detection process of Angular (and Vue and whatever else) works and how it can notify them when props change. |
@jonrimmer I agree that the current force-rendering approach is not best for all frameworks. I develop primarily with Angular so I understand your frustration. The PR that I put out, which uses the debouncing technique, was implemented to help improve what currently exists in the addon knobs codebase. @shilman + @igor-dv + @tmeasday, is the approach that @igor-dv brought up something that's currently being considered for the future of this addon? |
@ndelangen Can 2e30aeb#diff-d3a8a461a0bf5672a74aa09b8808b50e be reverted if there is no ability to fix this? |
@CodeByAlex how is the debouncing solution working for you in your project, and can we apply similar heuristics e.g. for the slider component? I've also suggested we post the update only on blur, which is a more extreme measure, but could further mitigate things. @jonrimmer are you volunteering to maintain knobs for angular? 😉 |
@shilman There should be no need to add debouncing for anything. All of the frameworks Storybook supports can easily handle thousands of updates per second. The only reason debouncing is necessary is because Storybook is tearing down and recreating the entire Angular app when anything changes. Imagine if, any time the user clicked a button, you completely destroyed and reinitialised your entire Angular app. Would you consider that a sane strategy? Would it pass code review? I'm guessing not. But this is exactly what Storybook is doing! And yes, I'd be happy to help out maintaining a working version of knobs for Angular if the alternative is having to accept Storybook shipping with a perpetually broken version. |
@jonrimmer I'd love to chat with you, would you be able to connect on our discord? |
Great Caesar's ghost!! I just released https://github.com/storybooks/storybook/releases/tag/v5.1.0-alpha.10 containing PR #6094 that references this issue. Upgrade today to try it out! Because it's a pre-release you can find it on the Closing this issue. Please re-open if you think there's still more to do. |
Bug or support request summary
Addon-knobs for Angular works in a very strange manner that impacts story loading performance.
Steps to reproduce
You can open browser console for this page:
https://storybooks-angular.netlify.com/?selectedKind=Addon%7CKnobs&selectedStory=All%20knobs&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybooks%2Fstorybook-addon-knobs&background=%2300aced
There should be "constructor" log message which logged by AllKnobsComponent. Then try to open another story then get back to "All knobs" again - you'll see double "constructor" message. Also changing any value in knob panel forces AllKnobsComponent to be recreated
Expected behavior
Changing values in knobs should only cause change detection for already loaded component without re initialization of component itself
Please specify which version of Storybook and optionally any affected addons that you're running
"@storybook/addons": "^4.0.0-alpha.18",
"@storybook/angular": "^4.0.0-alpha.18",
"@storybook/addon-knobs": "^4.0.0-alpha.18"
The text was updated successfully, but these errors were encountered: