nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
665 stars 169 forks source link

ERROR building surface (MS, SAS or AV) for structure 6X5S #802

Closed giagitom closed 3 years ago

giagitom commented 4 years ago

@fredludlow This is something strange happening only on structure 6X5S (tested MS, SAS or AV type and filterSelection ":A". This configuration should reproduce the error immediately, but it randomly happens also without filterSelection). I tested Firefox and Chrome, and they give the same results.

Uncaught TypeError: Cannot read property 'getPosition' of undefined
    at MolecularSurfaceRepresentation.createData (molecularsurface-representation.js:180)
    at structure-representation.js:165
    at Array.forEach (<anonymous>)
    at MolecularSurfaceRepresentation.create (structure-representation.js:161)
    at _make (representation.js:368)
    at after (molecularsurface-representation.js:159)
    at molecularsurface-representation.js:168
    at onSurfaceFinish (molecularsurface-representation.js:130)
    at Worker.<anonymous> (molecular-surface.js:99)
    at Worker.worker.onmessage (worker.js:24)

On AV surface only an additional error is shown in the console

worker.js:47 Worker.onerror molsurf 
ErrorEvent {isTrusted: true, message: "Uncaught RangeError: Invalid typed array length: Infinity", filename: "blob:null/954c0b75-9607-4543-8378-42b357e0e646", lineno: 2453, colno: 25, …}
bubbles: false
cancelBubble: false
cancelable: true
colno: 25
composed: false
currentTarget: Window {window: Window, self: Window, document: document, name: "", location: Location, …}
defaultPrevented: false
error: null
eventPhase: 0
filename: "blob:null/954c0b75-9607-4543-8378-42b357e0e646"
isTrusted: true
lineno: 2453
message: "Uncaught RangeError: Invalid typed array length: Infinity"
path: [Window]
returnValue: true
srcElement: Window {window: Window, self: Window, document: document, name: "", location: Location, …}
target: Window {window: Window, self: Window, document: document, name: "", location: Location, …}
timeStamp: 27043.87499999939
type: "error"
__proto__: ErrorEvent
fredludlow commented 3 years ago

Right, there's (at least) 2 issues:

  1. The AVHash class for the 'av' surface type doesn't check its inputs for sanity. I can trigger this Invalid typed array length: Infinity bug by specifying e.g. sele: ":B" and filterSele: ":A" (for any structure it seems)
  2. If I load the cif file for 6X5S it defaults to showing BU1 (biological unit 1), which is defined as an assembly of two parts (chain A and chain B) - and a surface gets built for each: here.

Fixing 1 is straightforward. For 2 I think the optimal solution is not doing any work at all when the intersection of sele and filterSele is empty...

I'll put together a PR