-
Notifications
You must be signed in to change notification settings - Fork 28
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
Image randomly blurred/upscaled (due to expand animation?) #57
Comments
Wow that's a weird bug. Thank you so much for the detailed report, will look into this as soon as possible. |
I tried to produce this with a big jpeg and png but I'm not able to. Tested on MacOS chrome 92 and Windows 10 Chrome 92. (Tested on Firefox and Safari as well just to be sure) FilePond calculates sizes in a requestAnimationFrame loop so there are no reflows during animations, while re-requesting Will leave this open though as it looks like something is up. |
Did a couple more tests and tracked it down to screen refresh rate:
I tried to screenshot page when hitting breakpoint in previewImageLoaded in both refresh rates, but to my eyes I don't see anything obvious between 60 Hz and 100 Hz views, just that root.rect.element.height is too small @ 100 Hz: |
calling requestAnimationFrame two times in a row before calling drawImage does help, but so does adding setTimeout(..., 10).
Just didn't find how root.height = ... results in actual element's height being set, but probably the fix would be to ensure that requestAnimationFrame(() => drawPreview...) is called after panel's height is set. |
Thank you so much for this info, I'm going to try and find a way to reproduce this and will get back to you. |
The issue is that I don't have a way to test this / reproduce the problem. Is there any way to simulate 100hz in chrome? Firefox has a |
I googled a bit, but didn't find such an option. But if you have any ideas/commits/PRs I can test it. |
Can you try replacing https://github.com/pqina/filepond-plugin-image-preview/blob/master/src/js/index.js#L172 with a I'm thinking maybe because of the high frame rate it runs before the height has been applied? |
When I changed those lines to
It seems to be stable now, but using 0ms or 10ms delays still resulted in same artifact. Another one that works and seems a bit cleaner to me:
|
can you remove the wrapping |
Still reproduces with this:
|
Alright, thanks for the quick test, so nested |
Published |
Wow, thanks! |
Describe the bug
Dropping an image to filepond sometimes renders it blurred/upscaled (container is bigger than image resized for preview) and sometimes it is working correctly.
To reproduce:
Context
Investigations/Solutions
It seems like container height is captured in the start of animation and is much less than it expands to. So image is resized to small image, but then container expands - at least that's my guess.
In
filepond-plugin-image-preview/src/js/view/createImageWrapperView.js
Line 298 in 1484606
If I change that to:
var previewContainerWidth = root.element.clientWidth; var previewContainerHeight = root.element.clientHeight;
then it seems to work correctly, but didn't have the time to properly validate this solution, yet.
Also using fixed height option
imagePreviewHeight
fix this problem as well.P.S. Really grateful for this project, it's a very nice plugin!
The text was updated successfully, but these errors were encountered: