-
Notifications
You must be signed in to change notification settings - Fork 209
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
Fix generateOutput called multiple times #1564
base: main
Are you sure you want to change the base?
Fix generateOutput called multiple times #1564
Conversation
This PR is work in progress, At the moment Resize, Crop & Constrained Crop module doesn't work correctly unless used with a setTimeout to generateOutput, This PR solves problem of QR not generating after merging #1532 and allows text-overlay module to work correctly in Node #1518 (finally!!!!) I appreciate all the help I can get because I am stuck now :( @jywarren @harshkhandeparkar @publiclab/is-reviewers |
I removed all the instances of setTimeout and added changePixel method to the modules, this makes them work without a problem, but I don't know why this is happening, for some reason code is async and when changePixel is added it runs after extramanipulation(which it shouldn't) and generates output, so if generate output is even removed from extramanipulation it would work fine, This type of behaviour shouldn't be in our code, this should work fine even when changePixel is not added!! And why is extraManipulation even called before changePixel? image-sequencer/src/modules/_nomodule/PixelManipulation.js Lines 235 to 245 in f6d5316
This piece of code seems to be the most likely culprit, so i set useWasm option on histogram to false and this was the output 😕 image-sequencer/src/modules/_nomodule/PixelManipulation.js Lines 279 to 283 in f6d5316
I think we should add a more if block here like this: if(!options.extraManipulation)
generateOutput(); This works fine!! @harshkhandeparkar you were working on #1515? have you found the solution to this?? |
Ok, so i changed pixelManipulation such that generateOutput will be called only once and extraManipulation will be called only after changePixel. |
At the moment these modules are not working
|
AddQr test was failing because it's benchmark was wrong, probably changed in #1550, I've updated it, It should pass now! |
All modules are working fine now 🎉 |
Codecov Report
@@ Coverage Diff @@
## main #1564 +/- ##
==========================================
- Coverage 66.67% 66.46% -0.22%
==========================================
Files 130 132 +2
Lines 2686 2821 +135
Branches 433 440 +7
==========================================
+ Hits 1791 1875 +84
- Misses 895 946 +51
|
@publiclab/is-reviewers @jywarren @harshkhandeparkar please review this!! |
@jywarren could you please take a look at this! |
Gosh @blurry-x-face a ton of your PRs are finally getting merged! Your work is dominating the upcoming release: https://github.com/publiclab/image-sequencer/projects/4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few questions :)
@@ -1,6 +1,8 @@ | |||
const ndarray = require('ndarray'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ndarray is imported here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying it shouldn't be necessary? Just checking, let's make a code suggestion perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see it's required again below. I'll remove that one.
src/modules/CanvasResize/Module.js
Outdated
function extraManipulation(pixels) { | ||
|
||
function extraManipulation(pixels, setRenderState, generateOutput, frames, f) { | ||
setRenderState(false); | ||
let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imported twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]); | |
let newPixels = ndarray(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]); |
src/modules/CanvasResize/Module.js
Outdated
/* | ||
* Changes the Canvas Size | ||
*/ | ||
const getPixels = require('get-pixels'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new import is added but doesnt look like it is used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const getPixels = require('get-pixels'); |
@@ -15,7 +15,12 @@ module.exports = function ConstrainedCrop(options, UI) { | |||
widthRatio = Number(aspectRatio[0]), | |||
heightRatio = Number(aspectRatio[1]); | |||
|
|||
function extraManipulation(pixels) { | |||
function changePixel(r, g, b, a) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? Wouldn't it add a redundant step?
if (!(renderableFrames < numFrames) && !(resolvedFrames < numFrames)) { | ||
|
||
// if(rend){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this comment for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if(rend){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the one clarification question for @blurry-x-face from @harshkhandeparkar -- and the other suggestions we should be able to accept and merge!
@@ -1,6 +1,8 @@ | |||
const ndarray = require('ndarray'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying it shouldn't be necessary? Just checking, let's make a code suggestion perhaps?
src/modules/CanvasResize/Module.js
Outdated
/* | ||
* Changes the Canvas Size | ||
*/ | ||
const getPixels = require('get-pixels'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const getPixels = require('get-pixels'); |
@@ -1,6 +1,8 @@ | |||
const ndarray = require('ndarray'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see it's required again below. I'll remove that one.
src/modules/CanvasResize/Module.js
Outdated
function extraManipulation(pixels) { | ||
|
||
function extraManipulation(pixels, setRenderState, generateOutput, frames, f) { | ||
setRenderState(false); | ||
let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]); | |
let newPixels = ndarray(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]); |
if (!(renderableFrames < numFrames) && !(resolvedFrames < numFrames)) { | ||
|
||
// if(rend){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if(rend){ |
Hi @harshkhandeparkar hope you're well, did you have a chance to look at my suggestions? If you agree we could go ahead and accept them... |
I am fine, ty! How are you? I did go through the suggestions but I was waiting for Rishabh. Do you think we should just commit those and merge or wait for him? |
Hi @jywarren @harshkhandeparkar I was a bit busy with university, I'll fix the PR ASAP, ty :) |
@harshkhandeparkar tests for edge detect are failing for some reason do you have any idea? |
Can you upload the expected and generated outputs? |
New output has slightly thicker edges at some places. Maybe some defaults changed or some options are wrong? |
It is still not the same as before. But it doesn't really matter. Should we change the benchmark image? |
Yea I think we should, except edge detect all other benchmarks seems to paas, what do you think @jywarren ? |
Sure that sounds good! Yeah I think the important takeaway here is that the
test is working to catch variations like this!
…On Wed, Nov 18, 2020, 2:44 AM Rishabh Shukla ***@***.***> wrote:
Yea I think we should, except edge detect all other benchmarks seems to
paas, what do you think @jywarren <https://github.com/jywarren> ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1564 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6JZMU7IZZSBK6QKAE73SQN3M3ANCNFSM4KKNYWHA>
.
|
If we update the edge detection expected output, we should be good here! |
Concerns this
Fixes #1575 Fixes #1515 Fixes #1457 Fixes #1532 (this)
Note: This PR is a work-in-progress
This PR fixes generateOutput called multiple times when extramanipulation is used.
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
npm run test-all
@publiclab/is-reviewers
for help, in a comment belowIf tests do fail, click on the red
X
to learn why by reading the logs.Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
Please make sure to get at least two reviews before asking for merging the PR as that would make the PR more reliable on our part
Thanks!