peaks.js icon indicating copy to clipboard operation
peaks.js copied to clipboard

Segment redraw bug in Firefox?

Open ffxsam opened this issue 4 years ago • 14 comments

Has anyone else ever seen anything like this in Firefox? I can't replicate it at all in Chrome nor Safari.

I'm not sure if this is a strange bug in Peaks.js, or a Firefox canvas bug.

https://user-images.githubusercontent.com/12532733/105121044-09739d00-5a99-11eb-8feb-9e922b164cc7.mp4

ffxsam avatar Jan 20 '21 02:01 ffxsam

Hey @ffxsam, did you manage to find the source for this? Happens to me on Chrome as well.

dutzi avatar Apr 12 '21 16:04 dutzi

@dutzi Unfortunately not, still an issue here - last time I checked, at least.

ffxsam avatar Apr 12 '21 17:04 ffxsam

@ffxsam, I think I found it, changing this block to:

this._drawWaveform(
  context,
  this._view.getWaveformData(),
  Math.round(frameOffset),
  Math.round(this._segment ? this._view.timeToPixels(this._segment.startTime) : frameOffset),
  Math.floor(this._segment ? this._view.timeToPixels(this._segment.endTime)   : frameOffset + width),
  width,
  height
);

Seems to fix this.

(I've wrapped the values with round and floor)

dutzi avatar Apr 12 '21 17:04 dutzi

I haven't observed this issue myself yet. I wonder why those changes fix it, do we have non-integer values somewhere?

chrisn avatar Apr 12 '21 17:04 chrisn

When playing around with the zoom factor, frameOffset would sometimes be n+0.5 (148.5, for example) 🤷‍♂️

dutzi avatar Apr 12 '21 17:04 dutzi

I think that the fraction values may originate from mousedown and mousemove events. I have just pushed a change that calls Math.floor() on those values, which hopefully fixes this issue.

chrisn avatar May 08 '21 11:05 chrisn

I think it happens when rendering peaks in a 4K or Retina displays. It might be that in such setup, dots cover 4 (or more) pixels, 2 per each axis, that would also explain why I only saw floats that look like x.5 (and not x.72, for example).

dutzi avatar May 08 '21 13:05 dutzi

Yes, I think you're right - although I haven't seen non-integer values on my Windows 10 laptop with 4K display. window.devicePixelRatio reports 2.25. Would you mind testing the change in https://github.com/bbc/peaks.js/commit/77440c9cccda638e0b20ccc09955515d2030c870 to see if it works for you?

chrisn avatar May 08 '21 13:05 chrisn

Still an issue in https://github.com/bbc/peaks.js/commit/426b49418325d5527fb9c2e0e59ab94dbf707424.

https://user-images.githubusercontent.com/12532733/117584936-5aa1ae00-b0d5-11eb-8896-39b3106d27c7.mp4

ffxsam avatar May 09 '21 19:05 ffxsam

I noticed there's some color bleed at the edges of the waveforms. I'm wondering if this has something to do with it, like one layer is clipping over the other one for some reason?

wave-edges

ffxsam avatar May 09 '21 19:05 ffxsam

I haven't been able to reproduce this locally, in Firefox or Chrome. Which OS and browser version are you using?

chrisn avatar May 09 '21 20:05 chrisn

macOS 10.15.7, Firefox 88.0.1. I believe this only occurs in Firefox.

ffxsam avatar May 09 '21 21:05 ffxsam

Thanks. I have no way to test this. Is it the case that WaveformZoomview._frameOffset is being set to a non-integer value? If so, what causes that to happen?

chrisn avatar May 09 '21 22:05 chrisn

I'll dig into this when I get a chance and let you know.

ffxsam avatar May 09 '21 22:05 ffxsam