-
Notifications
You must be signed in to change notification settings - Fork 9.1k
UI hangs when typing in request body #5113
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
Comments
Update: So I've been looking further into this as the UI is so slow it's blocking us from being able to use the newer Swagger UI. Whenever I type in the textarea of the requestBody the onChange method is called. This method calls a reducer which uses setIn on the state map. Expanding endpoint is also really slow. It takes around 5 seconds to expand any endpoint. The size of the example seems to have no impact on how long it takes to expand the operation. |
@LuukN2, what sort of hardware are you on? I see about 150ms of latency typing in More generally, I think it'd be a good idea to debounce the request body input's onChange, like we do for string parameter inputs today. At the very least it'd let you get multiple keystrokes in before getting choked up by the state changes. |
PS: interesting that you obfuscated your private API definition. Did you do that manually, or with a tool? |
@shockey Thanks for the response! I'm using a laptop with an i5-6200U CPU @ 2.30GHz and 8GB of RAM. As for the obfuscation I quickly wrote a tool with the help of another developer using jsonpaths to obfuscate parts of the spec. |
@shockey The performance is still blocking us from using the newer Swagger UI. Because react uses shallow comparison for updating elements this always results in shouldComponentUpdate in returning true for elements that reference parts of the immutable map since every time the state is changed so does the object reference. I check for relevant data changes in the properties passed to the element and only return true when they are present. It still has some issues since I'm not covering all cases where an element should rerender but it is mostly functional and when using a minified spec with these changes the UI is usable for us. I'll try to work out something issue free that we can personally use but your thoughts could be very helpful. |
I would also like to echo that this is still an issue. To make it easier for your team to debug I've created a StackBlitz deployment that uses the largest OpenAPI JSON spec I could find. You can test it here:
I've also attached a video below in which the following happens:
With what I've provided, you should be able to reproduce the issue very easily, but if you need anything else, please let me know. After taking a peek at the code, it seems like it would be a good amount of work to fix this. Very grateful for your work on Swagger UI and looking forward to seeing this fixed, thanks! 🙏 swagger-ui-reaact.performance.demo.mov |
Uh oh!
There was an error while loading. Please reload this page.
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
https://pastebin.com/raw/Zh5ZGN17
Note: This spec is obfuscated
Swagger-UI configuration options:
Swagger editor default settings
Describe the bug you're encountering
Every key press in the request body takes about ~800 ms to process. The ui hangs and freezes while typing and opening operations also takes a very long time.
To reproduce...
Steps to reproduce the behavior:
Expected behavior
The UI does not hang or only for a very short time when entering words in the request body text field.
Additional information
Callstack of a single key press event:

The text was updated successfully, but these errors were encountered: