Skip to content
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

[KED-2355] Update SVG-Crowbar to fix errors #339

Merged
merged 4 commits into from
Jan 7, 2021

Conversation

richardwestenra
Copy link
Contributor

@richardwestenra richardwestenra commented Dec 18, 2020

Description

We were originally using SVG-Crowbar v0.6.0, but started experiencing a critical CORS error with internal CSS in exported images, which was patched in #337. This PR updates the dependency version and reverts the patch.

Development notes

SVG-Crowbar v0.6.3 fixes the CORS issue, so we can revert the fix in #337.
However v0.6.2 introduced a call stack size error when exporting PNGs, which was resolved in v0.6.4.
However, v0.6.4 introduced an issue with PNG cropping that has been resolved in 0.6.5.
So in summary, we have now updated to v0.6.5 now that all of these errors have been resolved.

I've also added a small fix for console errors when exporting a null graph. If the graph doesn't exist and graphSize is empty, which can happen if the graph is still loading/rendering, or if all the filters are applied, then NaN console errors will be thrown. This commit prevents these errors.

QA notes

You will need to update/install the SVG-Crowbar dependency to test this fix.

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

Legal notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

  • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.

  • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorised to submit this contribution on behalf of the original creator(s) or their licensees.

  • I certify that the use of this contribution as authorised by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

SVG-Crowbar v0.6.3 fixes a CORS issue that we were facing, so we can revert the fix in #337.

However v0.6.2 seems to have introduced a new issue with PNG exports, so we cannot merge this change yet until it's fixed.
Copy link
Contributor

@studioswong studioswong left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@richardwestenra
Copy link
Contributor Author

richardwestenra commented Dec 18, 2020

@studioswong Thanks, but this isn't fixed yet, due to the new bug in SVG-Crowbar ~v0.6.2! We won't be able to update it to merge this PR and properly resolve this issue until that bug is fixed. Hence this is just a draft PR, and I'm gonna leave it here for when I pick this back up after xmas.

v0.6.2 introduced [a call stack size error](cy6erskunk/svg-crowbar#278) when exporting PNGs, which was resolved in v0.6.4.
However, v0.6.4 introduced [an issue with PNG cropping](cy6erskunk/svg-crowbar#75) that has been resolved in 0.6.5.
If the graph doesn't exist and graphSize is empty, which can happen if the graph is still loading/rendering, or if all the filters are applied, then NaN console errors will be thrown. This commit prevents these errors.
@richardwestenra richardwestenra marked this pull request as ready for review January 7, 2021 12:42
@studioswong
Copy link
Contributor

studioswong commented Jan 7, 2021

Thanks for the fix @richardwestenra , and great work for keeping a close eye and enduring all the SVG crowbar saga 👍

I just checked out the branch and both exports (SVG and PNG) works well 👍

Tried exporting the graph with all filters applied, while the export works fine ( it just exports an empty image with your theme background), I noticed that the console still throws errors for NaN and Infinity values ( see below). I guess we would need to apply a check for those x and y values as well to eliminate those errors?

image

Perhaps we might even need to rethink about those situations with the empty flowchart, perhaps we might even grey out the export function given these type of situations there is no graph?

All in all, thanks for the work!

let height = graphSize.height + graphSize.marginy * 2;
clone.setAttribute('viewBox', `0 0 ${width} ${height}`);
let width, height;
const hasGraph = graphSize.width && graphSize.height;
Copy link
Contributor

Choose a reason for hiding this comment

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

We might need to add the checks for valid values of width and height to eliminate those console errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! fixed 👍

if (hasGraph) {
clone.setAttribute('width', width);
clone.setAttribute('height', height);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be worth to rethink about the else scenerio for the empty flowchart - we could perhaps apply a standard width and height in the meantime for the sake of allowing us to still export and empty graph while we look into the flow when exporting an empty graph?

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 think it works as is without needing an explict height - I don't think we need to think any more about this extreme edge case. I tidied up the console errors for the sake of completeness as I don't like exposing uncaught errors, but I don't think it needs anything else tbh.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure thing, just tested and the errors are gone, so if it works without the need to manually specify a width and height then it's all good.

@richardwestenra richardwestenra changed the title Update svg-crowbar to fix error Update SVG-Crowbar to fix errors Jan 7, 2021
@richardwestenra richardwestenra merged commit 983b5d8 into main Jan 7, 2021
@richardwestenra richardwestenra deleted the fix/export-css-rules2 branch January 7, 2021 15:07
@richardwestenra richardwestenra changed the title Update SVG-Crowbar to fix errors [KED-2355] Update SVG-Crowbar to fix errors Jan 7, 2021
@richardwestenra richardwestenra mentioned this pull request Feb 17, 2021
1 task
richardwestenra added a commit that referenced this pull request Feb 19, 2021
# Release 3.9.0

## Major features and improvements

- Add code panel (#346)
- Improve view panning behaviour when a node is selected (#356, #363, #370, #373, #374)
- Improve layout performance for large graphs (#343)
- Save tag state to localStorage (#353)

## Bug fixes and other changes

- Improve graph layout code quality, performance and docs (#347)
- Update docs to remind on compatibility of Kedro-Viz 3.8.0 with Kedro 0.17 (#367)
- Update dependencies (#360, #364, #369)
- Fix failing CircleCI build on Windows (#365, #366)
- Refactor node-list-row CSS, fixing hover and focus states (#355, #358, #362)
- Update iconography (#357, #359)
- Fix missing indicator Chrome zoom bug (#349)
- Fix sidebar border/box-shadow CSS rules (#351)
- Fix server.py to work with versions >0.17 and update contributing docs (#348)
- Fix errors when scrolling with empty pipeline (#342)
- Ignore coverage on some branches and fix e2e tests (#345)
- Fix icon-button tooltips on mobile (#344)
- Update SVG-Crowbar to fix errors (#339)
- Update contributing docs for new dev server (#341)
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