-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Browser tab freezes, unresponsive, plus possible memory leak with form in modal #4018
Comments
I was able to reproduce this issue under the following conditions: After(I had to select a form input to get the tab to freeze and start using more CPU than necessary): |
@SharkFourSix @wesdevpro I was also able to reproduce the error on Safari and Chrome on my M1 mac. |
@SharkFourSix @wesdevpro It seems the validation message on a horizontally grouped field is causing the problem. |
Interesting. How were you able to pin it down to the grouped field? |
I removed the |
|
@wesdevpro @SharkFourSix So <template>
<b-field grouped horizontal label="Name">
<b-input placeholder="First name" required></b-input>
<b-input placeholder="Last name" required></b-input>
</b-field>
</template> |
@wesdevpro @SharkFourSix I confirmed that the problem did not happen in Buefy-next v0.1.2. |
@wesdevpro @SharkFourSix I was wrong, it happens in Buefy-next v0.1.2 too. But the browser did not freeze thanks to Vue 3's detecting infinite updates. |
The following buefy/src/components/field/Field.vue Lines 231 to 240 in f3a964d
|
The slot of the horizontally grouped <div class="field is-horizontal">
<b-field-body :message="formattedMessage" :type="newType">
<b-input placeholder="First name" required></b-input>
<b-input placeholder="Last name" required></b-input>
</b-field-body>
</div>
<div class="field is-horizontal">
<div class="field-body">
<b-field :message="formattedMessage" :type="newType">
<b-input placeholder="First name" required></b-input>
</b-field>
<b-field :type="newType">
<b-input placeholder="Last name" required></b-input>
</b-field>
</div>
</div> Please note that the above snippets are simplified to make explanation easier. Here are steps happening in the infinite updates:
|
So how can the cycle be broken given that it's a property change event rather a function call? |
@SharkFourSix @wesdevpro Possible solutions are
The first one needs deep comparison of two arbitrary values, which is not as easy as people might think. However, |
@SharkFourSix Btw, do you have any specific reason for combining <b-field horizontal label="Name">
<b-input placeholder="First name" required></b-input>
<b-input placeholder="Last name" required></b-input>
</b-field> I found Buefy was not designed to combine |
Well, for organizing the input fields. I have since changed the layout because the issue would have stalled my progress 😁. The problem along with its solution is worth a note though as I'm sure that someone else crazier than me will do the same thing at some point. |
…h form in modal (#4018) (#4021) * fix(lib): infinite Field updates - Fixes the bug that `Field` caused infinite recursions when both `grouped` and `horizontal` attributes were `true`, and a validation error was set. There were circular updates of the `newMessage` data field and the `message` prop of the child `Field`s. To break the loop, `watch` of the `message` prop makes sure that the contents of the new value are different from the `newMessage` data field before updating `newMessage`. Simple identity check won't work because `message` receives a brand new array every time. * test(lib): add test cases for Field with grouped and horizontal - Adds new test cases that test `Field` with `grouped` and `horizontal` attributes `true`. The test would never stop due to infinite recursions if the previous fix were not applied. * docs(CHANGELOG): update unreleased log - Adds the fix of `Field` freezing due to infinite recursions. - Explains the issue that remains after fixing the frozen Field bug. * chore(docs): add warning on grouped and horizontal (Field) - Adds warnings of not mixing `grouped` and `horizontal` props of `Field`.
…h form in modal (buefy#4018) (buefy#4021) * fix(lib): infinite Field updates - Fixes the bug that `Field` caused infinite recursions when both `grouped` and `horizontal` attributes were `true`, and a validation error was set. There were circular updates of the `newMessage` data field and the `message` prop of the child `Field`s. To break the loop, `watch` of the `message` prop makes sure that the contents of the new value are different from the `newMessage` data field before updating `newMessage`. Simple identity check won't work because `message` receives a brand new array every time. * test(lib): add test cases for Field with grouped and horizontal - Adds new test cases that test `Field` with `grouped` and `horizontal` attributes `true`. The test would never stop due to infinite recursions if the previous fix were not applied. Includes adaptation for @vue/test-utils V2: - `find(Component)` → `findComponent(Component)` - `findAll(Component)` → `findAllComponents(Component)` - `.at(i)` → `[i]` when accessing an item in `findAllComponents` results. @vue/test-utils V2 returns an ordinary array - `localVue` → `global: { components }`: @vue/test-utils V2 no longer supports `localVue` - `propsData` → `props`: `propsData` still works, but prepares for possible future deprecation * docs(CHANGELOG): update unreleased log - Adds the fix of `Field` freezing due to infinite recursions. - Explains the issue that remains after fixing the frozen Field bug. * chore(docs): add warning on grouped and horizontal (Field) - Adds warnings of not mixing `grouped` and `horizontal` props of `Field`.
…h form in modal (buefy#4018) (buefy#4021) * fix(lib): infinite Field updates - Fixes the bug that `Field` caused infinite recursions when both `grouped` and `horizontal` attributes were `true`, and a validation error was set. There were circular updates of the `newMessage` data field and the `message` prop of the child `Field`s. To break the loop, `watch` of the `message` prop makes sure that the contents of the new value are different from the `newMessage` data field before updating `newMessage`. Simple identity check won't work because `message` receives a brand new array every time. * test(lib): add test cases for Field with grouped and horizontal - Adds new test cases that test `Field` with `grouped` and `horizontal` attributes `true`. The test would never stop due to infinite recursions if the previous fix were not applied. Includes adaptation for @vue/test-utils V2: - `find(Component)` → `findComponent(Component)` - `findAll(Component)` → `findAllComponents(Component)` - `.at(i)` → `[i]` when accessing an item in `findAllComponents` results. @vue/test-utils V2 returns an ordinary array - `localVue` → `global: { components }`: @vue/test-utils V2 no longer supports `localVue` - `propsData` → `props`: `propsData` still works, but prepares for possible future deprecation * docs(CHANGELOG): update unreleased log - Adds the fix of `Field` freezing due to infinite recursions. - Explains the issue that remains after fixing the frozen Field bug. * chore(docs): add warning on grouped and horizontal (Field) - Adds warnings of not mixing `grouped` and `horizontal` props of `Field`.
Overview of the problem
Buefy version: 0.9.28
Vuejs version: 2.7.16
OS/Browser: Ubuntu 22, Firefox, Brave
Description
Whenever the modal opens and captures focus or when you start typing into the form fields, the tab will freeze.
Steps to reproduce
Expected behavior
Tab should not lock up or have memory spike
Actual behavior
Inspecting CPU usage in the browser's Task Manager shows memory usage growing rapidly and CPU usage stays at 100%
The text was updated successfully, but these errors were encountered: