Skip to content

Commit 82ae6e3

Browse files
committed
Apply patch only to invalid edges
Ref: Ref: Random "Script Error" thrown when generating nodes and edges in newest webgl version #3365
1 parent 4abef71 commit 82ae6e3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/extensions/renderer/canvas/webgl/drawing-elements-webgl.mjs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,10 @@ export class ElementDrawingWebGL {
556556
return;
557557
}
558558

559-
// Edges are not drawn as textures
560-
// Edges with invalid points could be passed here, causing errors
559+
// Edges with invalid points could be passed here (labels), causing errors
561560
// Ref: Random "Script Error" thrown when generating nodes and edges in newest webgl version #3365
562561
// https://github.com/cytoscape/cytoscape.js/issues/3365
563-
if(ele.isEdge()) {
562+
if(ele.isEdge() && !this._isValidEdge(ele)) {
564563
return;
565564
}
566565

@@ -997,11 +996,21 @@ export class ElementDrawingWebGL {
997996
}
998997
}
999998

999+
_isValidEdge(edge) {
1000+
const rs = edge._private.rscratch;
1001+
1002+
if( rs.badLine || rs.allpts == null || isNaN(rs.allpts[0]) ){ // isNaN in case edge is impossible and browser bugs (e.g. safari)
1003+
return false;
1004+
}
1005+
1006+
return true;
1007+
}
1008+
10001009
_getEdgePoints(edge) {
10011010
const rs = edge._private.rscratch;
10021011

10031012
// if bezier ctrl pts can not be calculated, then die
1004-
if( rs.badLine || rs.allpts == null || isNaN(rs.allpts[0]) ){ // isNaN in case edge is impossible and browser bugs (e.g. safari)
1013+
if(!this._isValidEdge(edge)){ // isNaN in case edge is impossible and browser bugs (e.g. safari)
10051014
return;
10061015
}
10071016
const controlPoints = rs.allpts;

0 commit comments

Comments
 (0)