Re: Limit of 32 Canvas

Liedl Johann wrote:
> My application creates more than 32 DisplayImpl (in different windows). 
> On creating the 32nd object an Exception occurs in the 
> javax.media.j3d.MasterControl.getCanvasBit() method. I decompile this 
> class. The source code is the following one:
> 
> int getCanvasBit() {
>    synchronized (canvasBitFreeList) {
>       if (canvasBitFreeList.size() == 0) {
>           if (canvasBitCount > 31)
>              throw new InternalError();
>            return 1 << canvasBitCount++;
>       }
>       return ((Integer) canvasBitFreeList.removeLastElement()).intValue();
>   }
> }
> 
> I know that this is not a visad class, but does anyone known the reason 
> for this limitation (maybe a limit in the opengl API)

Well, just looking at the code, one can see that it's returning
a 32-bit integer value in which a single bit is set to indicate
which canvas is being used.  Odds are good that at some other
place in the code, there's an 'int' which has multiple bits
set to indicate something about the canvases (which ones need
to be updated, which ones have pending events, etc.)

Sun could change this "canvas bit" to a 'long', but that'd only extend
the limit up to 64 canvases and would possibly take quite a bit
of re-engineering.  (I don't have the source, so I can't say how
much work that would be...)