Re: Weird display problem

  • To: Tennessee James Leeuwenburg <tjl@xxxxxxxxxx>
  • Subject: Re: Weird display problem
  • From: Bill Hibbard <billh@xxxxxxxxxxxxx>
  • Date: Tue, 16 Sep 2003 05:56:09 -0500 (CDT)
Hi Tennessee,

> I'd like to understand a little more about how DisplayImpl's do their
> threading.

DisplayImpl extends ActionImpl, which has a run() method
that is invoked by a Thread from visad.util.ThreadPool
when a triggering even occurs. The run() method invokes
the DisplayImpl.doAction() method, which does all the
work. Calls to numerous other methods of DisplayImpl, as
well as methods of ScalarMap, Control (and its numerous
subclasses), linked Data and linked collaborative
DisplayImpls trigger calls to DisplayImpl.doAction().

There is quite a bit of detail in the DataRenderer tutorial.

> I am adding layers - that is a (scalarmap, datareference) - to the
> display in batches. In terms of my application a model is made up of a
> number of layers. Models get added or removed, and as this happens each
> layer also gets added and removed.
>
> The strange behaviour that I am getting is some data is becoming
> inaccessible. If I add the layers for one model, I am able to toggle
> them on and off with renderer.toggle(). Which is great. However, if I
> add a second model, the new layers cannot be toggled until I remove the
> first model.

Are the new layers stuck in the toggled on or toggled off
state?

> Which is odd. So, I am suspicious that there is a deadlock or thread
> conflict occurring which is preventing the data from displaying, but I
> don't understand the execution logic of DisplayImpl nearly well enough.
> My procedure for adding a model is to loop over the list of layers, and
> add each one to the display. There is also some GUI logic in there, but
> I can replicate the error even with the GUI stuff stripped out. VisAD is
> definately getting the data and the scalarmaps, because I am printing
> out Dispay.getMapVector() and getting results. And, as soon as I remove
> the reference to all the layers from the new model, the data appears all
> of a sudden.

If you can toggle any layers on and off then there is no
deadlock, since all DataRenderer.doAction() methods are
invoked in a single loop (at about lines 1684-1699 of
DisplayImpl.java).

A good way to analyze deadlocks is to run under jdb. When
you think you have a deadlock, enter the jdb commands
'suspend all' and 'where all'. This will give you a stack
dump with line numbers for each Thread, and you can see
where Threads are waiting inside synchronized() {...}
statements.

> I'm totally baffled, and can't see why this might be occurring. Is there
> anything I should be aware of in terms of having multiple renderers
> floating around, or some common problems that people run into with VisAD
> threading?
>
> Sorry if this is all very vague, but like I said, I'm baffled. As far as
> my code is concerned, adding a new model is as simple as adding some
> more layers - models are a concept that VisAD is not aware of! So, why
> would it work for multiple layers in one model?

One thing to seriously consider is whether the ScalarMaps
from the first models are interfering with the rendering
of data from later models. If the later models seem to be
stuck off, this could be the explanation. There is no
segregation of ScalarMaps by model (as you say, VisAD is
unaware of your models) - all ScalarMaps apply to all
linked DataReferences.

Let us know if you have more questions or manage to figure
this out.

Good luck,
Bill