Error: Non-real measuredBounds has been set. Object Picture()#1159

I am getting the following in my GOJS code:

Error: Non-real measuredBounds has been set. Object Picture()#1159, measuredBounds: Rect(NaN,NaN,NaN,NaN)

What is strange is the error went away after a couple times going to the same HTML view. But now it is back, but nothing in my code has changed.

I thought it was maybe called when I was drawing the images from the generateImages function that i call to do a makeSvg call. However, this is what happens when I make alerts to assert that certain things have executed.

The error is being thrown between setting the Diagram.model to array of JSON objects describing each Node and InitialLayoutCompleted being triggered. Any ideas? Help much appreciated!

You should set the Picture.desiredSize (or, equivalently, the Picture.width and Picture.height).

If you don’t set it (or do something similar), the Picture will get the natural size of the image. But since the availability of the image might happen sooner or later depending on network issues and caching, GoJS might not know for a while what size the image is really supposed to be.

You shouldn’t be getting an error though. What version of GoJS are you using?

I am using: GoJS v1.5.7

does desiredSize correspond to the size parameter of makeSvg? I am not actually dealing with a Picture object or class., unless it is a SuperClass of what makeSvg produces.

This is what I am calling makeSvg with:

 img = confSheetDiagramRef.makeSvg({
        scale: 1,
                    details: 1,
        position: new go.Point(p.x + j, p.y + i),
        size: new go.Size(imgWidth, imgHeight)

And i confirm that both the width and height are not NAN in the code before I make this call.

Can this type of error be thrown in another context otherthan make Images of Diagrams? Such as in the setup of the Diagram itself or when defining Node data or Node templates?

I wasn’t talking about the call to Diagram.makeSvg, but about some Picture in some Part somewhere in your Diagram.

Interesting. So I have upgraded to the most recent stable version of GoJS.

What is interesting is that I don’t actually have any Picture in any part in my diagram. I have created a template
for Nodes that contain Pictures (see line 338 here But there is no node in my Diagram.model.nodeArray which uses that particular template, and therefore, no Node in my Diagram containing a Part of type Picture. Can the error be thrown even with an unused Node Template which contains a Picture?

So it turns out I was actually making Nodes of the “Image” template (which has a Picture Part) without calling the Picture.desiredSize and therefore was getting the error.

Thank you for your help!