Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/extensions/renderer/canvas/webgl/drawing-elements-webgl.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,13 @@ export class ElementDrawingWebGL {
return;
}

// Edges with invalid points could be passed here (labels), causing errors
// Ref: Random "Script Error" thrown when generating nodes and edges in newest webgl version #3365
// https://github.com/cytoscape/cytoscape.js/issues/3365
if(ele.isEdge() && !this._isValidEdge(ele)) {
return;
}

if(this.renderTarget.picking && opts.getTexPickingMode) {
const mode = opts.getTexPickingMode(ele);
if(mode === TEX_PICKING_MODE.IGNORE) {
Expand Down Expand Up @@ -989,11 +996,21 @@ export class ElementDrawingWebGL {
}
}

_isValidEdge(edge) {
const rs = edge._private.rscratch;

if( rs.badLine || rs.allpts == null || isNaN(rs.allpts[0]) ){ // isNaN in case edge is impossible and browser bugs (e.g. safari)
return false;
}

return true;
}

_getEdgePoints(edge) {
const rs = edge._private.rscratch;

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