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

fix: nondeterminism in renderer #1316

Merged
merged 5 commits into from
Feb 22, 2023
Merged

fix: nondeterminism in renderer #1316

merged 5 commits into from
Feb 22, 2023

Conversation

wodeni
Copy link
Member

@wodeni wodeni commented Feb 14, 2023

Description

Resolves #1312.

Implementation strategy and design decisions

  • In Line.ts, stop using uuid.v4 for unique ID generation
  • Instead, Render* functions take in name, a client-provided id for the diagram instance to be rendered. And names in the SVG are disambiguated from others instances by a unique instance id.
  • Similarly, Simple and GridBox take in name too.
  • Remove uuid from core's dependencies
  • Note that this PR doesn't solve References in CSS style of imported SVGs not rendered correctly #1307

Examples with steps to reproduce them

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new ESLint warnings
  • I have reviewed any generated registry diagram changes

Open questions

Questions that require more discussion or to be addressed in future development:

@samestep
Copy link
Collaborator

Looks like packages/core/package.json changed but yarn.lock didn't; could you run yarn?

Copy link
Collaborator

@samestep samestep left a comment

Choose a reason for hiding this comment

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

Quick note about backwards compatibility before I review the rest.

packages/core/src/index.ts Outdated Show resolved Hide resolved
packages/core/src/index.ts Outdated Show resolved Hide resolved
@samestep
Copy link
Collaborator

I guess the name prop for the Simple component also needs to be optional.

@github-actions
Copy link

github-actions bot commented Feb 14, 2023

± Registry diff

M	3d-projection-fake-3d-linear-algebra.svg
M	arrowheads-arrowheads.svg
M	collinear-euclidean.svg
M	continuousmap-continuousmap.svg
M	matrix-matrix-addition-matrix-ops.svg
M	matrix-matrix-division-elementwise-matrix-ops.svg
M	matrix-matrix-multiplication-elementwise-matrix-ops.svg
M	matrix-matrix-multiplication-matrix-ops.svg
M	matrix-matrix-subtraction-matrix-ops.svg
M	matrix-transpose-matrix-ops.svg
M	matrix-vector-left-multiplication-matrix-ops.svg
M	matrix-vector-right-multiplication-matrix-ops.svg
M	parallel-lines-euclidean.svg
M	persistent-homology-persistent-homology.svg
M	scalar-vector-division-matrix-ops.svg
M	scalar-vector-left-multiplication-matrix-ops.svg
M	scalar-vector-right-multiplication-matrix-ops.svg
M	siggraph-teaser-euclidean-teaser.svg
M	tree-tree.svg
M	tree-venn-3d.svg
M	two-vectors-perp-vectors-dashed.svg
M	vector-vector-addition-matrix-ops.svg
M	vector-vector-division-elementwise-matrix-ops.svg
M	vector-vector-multiplication-elementwise-matrix-ops.svg
M	vector-vector-outerproduct-matrix-ops.svg
M	vector-vector-subtraction-matrix-ops.svg
M	vector-wedge-exterior-algebra.svg

📊 Performance

Key

Note that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.

     0s   1s   2s   3s   4s   5s   6s   7s   8s   9s
     |    |    |    |    |    |    |    |    |    |
name ▝▀▀▀▀▀▀▀▀▀▀▀▚▄▄▄▄▄▄▄▄▄▞▀▀▀▀▀▀▀▀▀▀▀▀▚▄▄▄▄▄▄▄▄▄▖
      compilation labelling optimization rendering

Data

                                                    0s   1s   2s   3s   4s   5s   6s   7s
                                                    |    |    |    |    |    |    |    |
3d-projection-fake-3d-linear-algebra                ▝▞▖
allShapes-allShapes                                 ▝▚▚▄
arrowheads-arrowheads                               ▝▞▖
caffeine-structural-formula                         ▝▀▀▀▞▚
center-shrink-circle-animation                      ▝▞▖
circle-example-euclidean                            ▝▀▚▀▀▚
closest-point-test-closest-point                    ▝▀▀▀▀▀▚▚
collinear-euclidean                                 ▝▀▞▖
congruent-triangles-euclidean                       ▝▀▀▞▖
continuousmap-continuousmap                         ▝▞▖
cubic-bezier-cubic-bezier                           ▝▚▀▀▖
glutamine-molecules-basic                           ▝▀▞▖
half-adder-distinctive-shape                        ▝▚▚
hypergraph-hypergraph                               ▝▀▀▀▚▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚
incenter-triangle-euclidean                         ▝▀▞▖
lagrange-bases-lagrange-bases                       ▝▚▚
matrix-matrix-addition-matrix-ops                   ▝▚▚
matrix-matrix-division-elementwise-matrix-ops       ▝▚▚
matrix-matrix-multiplication-elementwise-matrix-ops ▝▚▚
matrix-matrix-multiplication-matrix-ops             ▝▚▚
matrix-matrix-subtraction-matrix-ops                ▝▚▚
matrix-transpose-matrix-ops                         ▝▚▚
matrix-vector-left-multiplication-matrix-ops        ▝▚▚
matrix-vector-right-multiplication-matrix-ops       ▝▚▚
midsegment-triangles-euclidean                      ▝▀▞▖
mobius-mobius                                       ▝▞▖
non-convex-non-convex                               ▝▚▚
one-water-molecule-atoms-and-bonds                  ▝▞▖
parallel-lines-euclidean                            ▝▀▞▚
persistent-homology-persistent-homology             ▝▀▀▞▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▚▖
points-around-line-shape-distance                   ▝▀▞▖
points-around-polyline-shape-distance               ▝▀▚▚
points-around-star-shape-distance                   ▝▀▀▀▞▖
quaternion-group-group-theory-cayley-graph          ▝▀▚▚
quaternion-group-group-theory-multiplication-table  ▝▀▀▚▞▖
scalar-vector-division-matrix-ops                   ▝▚▚
scalar-vector-left-multiplication-matrix-ops        ▝▚▚
scalar-vector-right-multiplication-matrix-ops       ▝▚▚
siggraph-teaser-euclidean-teaser                    ▝▀▞▖
small-graph-disjoint-rect-line-horiz                ▝▀▚▚
small-graph-disjoint-rects                          ▝▞▖
small-graph-disjoint-rects-large-canvas             ▝▞▖
small-graph-disjoint-rects-small-canvas             ▝▞▖
tree-tree                                           ▝▚▚
tree-venn                                           ▝▀▚▚
tree-venn-3d                                        ▝▀▞▄
two-triangles-triangle-mesh-3d                      ▝▚▚
two-vectors-perp-vectors-dashed                     ▝▞▖
vector-vector-addition-matrix-ops                   ▝▚▚
vector-vector-division-elementwise-matrix-ops       ▝▚▚
vector-vector-multiplication-elementwise-matrix-ops ▝▚▚
vector-vector-outerproduct-matrix-ops               ▝▚▚
vector-vector-subtraction-matrix-ops                ▝▚▚
vector-wedge-exterior-algebra                       ▝▚▚
wet-floor-atoms-and-bonds                           ▝▚▀▚
word-cloud-example-word-cloud                       ▝▀▞▖
wos-laplace-estimator-walk-on-spheres               ▝▀▚▚
wos-nested-estimator-walk-on-spheres                ▝▀▀▚▀▀▀▖
wos-offcenter-estimator-walk-on-spheres             ▝▀▚▀▀▀▚
wos-poisson-estimator-walk-on-spheres               ▝▀▚▀▚

@cloudflare-pages
Copy link

cloudflare-pages bot commented Feb 20, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1ba7088
Status: ✅  Deploy successful!
Preview URL: https://11c074be.penrose-72l.pages.dev
Branch Preview URL: https://fix-seed.penrose-72l.pages.dev

View logs

@wodeni wodeni requested a review from samestep February 20, 2023 22:06
@codecov
Copy link

codecov bot commented Feb 21, 2023

Codecov Report

Merging #1316 (1ba7088) into main (0d52677) will decrease coverage by 0.03%.
The diff coverage is 16.66%.

@@            Coverage Diff             @@
##             main    #1316      +/-   ##
==========================================
- Coverage   61.30%   61.28%   -0.03%     
==========================================
  Files          63       63              
  Lines        7826     7829       +3     
  Branches     1842     1845       +3     
==========================================
  Hits         4798     4798              
- Misses       2922     2924       +2     
- Partials      106      107       +1     
Impacted Files Coverage Δ
packages/core/src/index.ts 42.85% <0.00%> (-0.70%) ⬇️
packages/core/src/renderer/Renderer.ts 25.92% <ø> (ø)
packages/core/src/renderer/Line.ts 2.80% <33.33%> (-0.03%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Collaborator

@samestep samestep left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@wodeni wodeni merged commit 9795420 into main Feb 22, 2023
@wodeni wodeni deleted the fix-seed branch February 22, 2023 20:54
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.

Determinism is broken
2 participants