question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delay when using declarative widthCallback

See original GitHub issue

I am seeing a delay when using the widthCallback. My code is simple enough:

<mesh
  ref={mesh}
  rotation={[0, Math.PI, 0]}
>
  <meshLine
    attach="geometry"
    points={points}
    widthCallback={pointWidth => pointWidth * 5 * Math.random()}
  />
  <meshLineMaterial
    attach="material"
    lineWidth={width}
    color={color}
  />
</mesh>

I see this: Screen Shot 2020-10-22 at 6 24 30 PM

and then after waiting a long time (1-3 minutes), I get the desired: Screen Shot 2020-10-22 at 6 28 26 PM

Any guess? The function component doesn’t appear to be stale - it’s on a timer and rendering twice a second

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ryanking1809commented, Oct 30, 2020

I should be able to find the time to test it later in the weekend but if you have the time basically this.widthCallback needs to be replaced with a getter for declarative architectures so we can do a redraw. I imagine if you added the following to Object.defineProperties on line 32 it should work.

      widthFunction: {
        enumerable: true,
        get: function() {
          return this.widthCallback;
        },
        set: function(value) {
          this.widthCallback= value;
          // this should redraw the line with the new width function
          // it might be necessary to check if points exist before running this
          // as it can be executed before points are defined
          this.process();
        },
      },

Then we use the new getter

<meshLine
    attach="geometry"
    points={points}
    widthFunction={pointWidth => pointWidth * 5 * Math.random()}
  />

You could alternatively keep the widthCallback name and rename all the existing reference to _widthCallback

1reaction
ryanking1809commented, Oct 29, 2020

Hmm looks like it doesn’t redraw with widthCallback. If you set the widthCallback before you set the points it should work. I imagine the delay is a result of waiting for the component to rerender in which setPoints is called again. Should be able to do a PR to fix.

<meshLine
    attach="geometry"
    widthCallback={pointWidth => pointWidth * 5 * Math.random()}
    points={points}
  />

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delay region playback in Logic Pro - Apple Support
You can shift the playback position of regions on a track using the Delay parameter. Positive values shift regions ahead in time (laid-back...
Read more >
Latency Issues with Interfaces – Focusrite Audio Engineering
When you are recording audio with your interface, you might notice a slight delay in the audio coming back to you. This delay...
Read more >
The audio and video are out of sync or there is an audio delay.
If the TV is connected to a soundbar or home theater system (with an HDMI cable or optical cable), the sound may be...
Read more >
Audio Latency for VoIP - How it Impacts Call Quality & Ways to ...
Two-way latency measures the round trip time. Both measurements can affect the customer journey with VoIP. Here, we take a deeper dive into ......
Read more >
Our Soundbar Connectivity Tests: Latency - RTINGS.com
High latency or audio lag is a surefire way to ruin a climactic ... High latency can be noticeable mostly with lip sync...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found