Skip to content
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

Wheelpicker performance issues #2999

Open
2 of 7 tasks
Excustic opened this issue Mar 26, 2024 · 0 comments · Fixed by qburst/react-native-ui-lib-1#3 · May be fixed by #3026
Open
2 of 7 tasks

Wheelpicker performance issues #2999

Excustic opened this issue Mar 26, 2024 · 0 comments · Fixed by qburst/react-native-ui-lib-1#3 · May be fixed by #3026
Labels
bug a bug in one of the components

Comments

@Excustic
Copy link

Description

When inserting a list with >30 label-value pairs, the WheelPicker becomes almost unresponsive and slow.

Related to

  • Components
  • Demo
  • Docs
  • Typings

Steps to reproduce

  1. Create a Wheelpicker component in your return statement.
  2. Insert a list with more than 30 label-value pairs.
  3. Open the app and try scrolling through the WheelPicker.
  4. Lagging should be noticeable.

Expected behaviour

The WheelPicker should be easy to use and scroll smoothly.

Actual behaviour

The WheelPicker is lagging, causing confusion and incorrect feedback.

More Info

The issue seems to reside with the component assigning an event's contentOffset.y to a SharedValue offset on every scroll.

On their own, whether assigning a constant value to the SharedValue or logging contentOffset.y on every scroll, doesn't seem to impact performance.

My conclusion is that assigning an ever-changing variable to offset leads somehow to a behaviour which internally that messes with the rendering, causing stuttering.

How to remove lag

  1. Go to node_modules/react-native-ui-lib/src/components/WheelPicker/index.js
  2. Find the constant scrollHandler in index.js
  3. comment out the following line:
 offset.value = e.contentOffset.y;

Code snippet

const range = (min, max) => {
        console.log(min, max, "minmax")
        var range = new Array(max-min)
        for(let i=min; i <= max; i++)
            range[i-min] = i
        return range.map(value => {return {label: value.toString(), value}})
    }
const fieldRange = useMemo(()=>range(dialogOptions.min, dialogOptions.max), [])
.
.
.
<WheelPicker 
              numberOfVisibleRows={5}
              initialValue={'0'} 
              items={fieldRange}>
                    
 </WheelPicker>

Screenshots/Video

Expected behaviour:
Record_2024-03-26-15-41-19-expected
Actual behaviour:
Record_2024-03-26-15-41-19

Environment

  • React Native version: 0.70.5
  • React Native UI Lib version: ^7.18.3

Affected platforms

  • Android
  • iOS
  • Web
@Excustic Excustic added the bug a bug in one of the components label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in one of the components
Projects
None yet
1 participant