Skip to content

Conversation

Smrtnyk
Copy link
Contributor

@Smrtnyk Smrtnyk commented May 18, 2025

No description provided.

Copy link

codesandbox bot commented May 18, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

golden: `${operation}.png`,
snapshotSuffix: 'gco',
percentage: 0.04,
size: [size.width, size.height],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asturur 4 tests are failing on node side on my local machine and I can't figure out why
you can focus them if you put only: true in here in options
then only this test file will be focused

I am not sure why tests just don't want to pass (these 4) on node side, might be my local machine
they do work just fine in playwright in browser

I tripple checked that I migrated the script properly from qunit, can't spot something that I missed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only difference i see is creating a new existing each test rather than cloning it. The difference would be that in one case is a canvas, in the other is an image probably created from a dataurl, so it is kind of reset from the canvas operations we did to create that particular gradient. is an unexpected failure tho,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean each test should be purely independent and not rely on any kind of state of a previous test case
otherwise it is a brittle testing practice and a footgun in the long run

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is weird it passes the browser step, meaning chromium properly generates the proper image
but node part fails, it ends up being without these generated circles

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah my comment about image vs canvas was that maybe node-canvas internally could have a canvas tainted in some way with the global composite operation, not that would bleed test by test. But i tried to change it to an image and nothing really changed

Copy link
Contributor

Build Stats

file / KB (diff) bundled minified
fabric 914.662 (0) 301.450 (0)

size: [size.width, size.height],
async renderFunction(canvas, fabric) {
// goldens are transparent
canvas.backgroundColor = 'transparent';
Copy link
Contributor Author

@Smrtnyk Smrtnyk May 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this, since goldens are transparent and in global beforeEach in playwright we set it to white for some reason so then there is a mismatch in the background color when comparing snapshots

@Smrtnyk Smrtnyk closed this May 18, 2025
@Smrtnyk Smrtnyk reopened this May 18, 2025
@asturur
Copy link
Member

asturur commented May 19, 2025

ok if i have to dig in those tests i ll need some time.

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented May 19, 2025

ok if i have to dig in those tests i ll need some time.

no worries we are not in a hurry

@asturur
Copy link
Member

asturur commented May 20, 2025

my gut feeling is that all nodes test are somehow failing and that those are the one that are more visibile, playwright has its own measurment that differs probably? with the current master ti should be possible to create the snasphots by deleting them and running the visual tests in node, i want to see what does node creates today, since we update it substantially.

@asturur
Copy link
Member

asturur commented May 20, 2025

let me do a discovery test again

@asturur
Copy link
Member

asturur commented May 20, 2025

i switched the drawing operation order between the small preview and the big gradient to see if it changes anything. Is like the background gets deleted in node after the first small draw, that with the operations that are failing seems to match what should happen.

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented May 20, 2025

my gut feeling is that all nodes test are somehow failing and that those are the one that are more visibile, playwright has its own measurment that differs probably? with the current master ti should be possible to create the snasphots by deleting them and running the visual tests in node, i want to see what does node creates today, since we update it substantially.

I don't think all node test cases are failing
there have been a numerous occasions when I migrated existing goldens to the plawyright from qunit that tests would fail on node side due to some mismatch
also for all others it does generate a proper image output, but only for these 4 it is empty
locally you can add only: true to the rendering test case options to focus single test case
comment out the browser step and remove existing golden and see what node generates

I feel like something might be issue in fabric itself or we have some race condition in the testing framework where compare too early before it is generated?

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented May 20, 2025

there is something interesting
If you remove this preview creation from the canvas.add
and do it like this

canvas.add(
          createNew(fabric, operation),
        );

then the test passes
I have deleted the golden to see which one it will create, it is creating the same one as expected except this thing in the upper left corner (the preview thingy) and it probably passes since it matched enough pixels

I don't get why is this different than in qunit
since tests are running on node side, in both playwright and in qunit
so it is the same node version and same fabric code, same node-canvas library

width: 30,
height: 30,
fill: 'red',
globalCompositeOperation: operation,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok if we remove this line the test works just fine for all of the cases for both node and browser
now, why does this line break the tests, no idea

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented May 20, 2025

I have pushed a commit that made the tests pass
now why that fixes the tests I have 0 idea, but there might be some internal fabric bug with handling 2 gco operations
my knowledge of fabric internals is limited
please have a look
seems like this creates output to match enough pixels for all tests to pass

@asturur
Copy link
Member

asturur commented May 20, 2025

ok your change made me understand where the issue is.
Node by default has caching off.
And the group with r1 and r2 is uncached.
that means that r2 in the case of destination out is killing everything else that is not composing with the small red rectangle.

@Smrtnyk
Copy link
Contributor Author

Smrtnyk commented May 20, 2025

ok your change made me understand where the issue is. Node by default has caching off. And the group with r1 and r2 is uncached. that means that r2 in the case of destination out is killing everything else that is not composing with the small red rectangle.

Amazing
We are close to getting rid of qunit

@asturur asturur merged commit 2b64173 into fabricjs:master May 20, 2025
16 of 17 checks passed
@Smrtnyk Smrtnyk deleted the move-gco branch May 21, 2025 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants