You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by vyang <vy...@apt-cafm.com> on 2009/09/02 16:01:26 UTC

Re: Update Manager Failing

I think I've found the problem.  With slower computer canvas double buffering
might be too slow which cause an interruption in the update manager.  

Now with my code below, I'm just wondering if its a good idea/good coding to
put updatemanager runnables inside a swing worker.  The swingworker is used
to display an progress bar only (I believe).  I've read somewhere that the
progress bar should be run under swingutilities runnable.

vyang


vyang wrote:
> 
> Hello,
> 
> I'm having a bit of a problem with update manager failing.  On a faster
> computer there seems to be no problem but on a slower computer update
> manager seems to fail.  It seems like there is an interruption to update
> manager so it fails thus not updating my canvas.  I always thought that
> update managers runnables are put into a queue and gets called when one is
> finished.  
> 
> my code is as follows:
> 
> Vector finalDrawingLayers = drawingLayers;
> Vector finalLayerSetLayers = layerSetLayers;
> 
> SwingWorker worker = new SwingWorker(){
>                 public Object construct() {
>                     try {
>                        
> finalDrawingPanel.getUpdateManager().getUpdateRunnableQueue().invokeAndWait(new
> Runnable(){
>                             public void run() {
>                                 if (!finalIsFirstLoad) {
>                                     updateLayers(finalDrawingLayers);
> //layers to turn off
>                                     updateLayers(finalLayerSetLayers);
> //layers to turn on
>                                 } else {
>                                    
> updateLayersOnLoad(finallayerstorender);
>                                 }
>                             }
>                         });
>                     } catch (InterruptedException ie) {
>                         ie.printStackTrace();
>                     }
>                     
>                     return null;
>                 }
>                 
>                 public void finished() {
>                     renderColoring();
>                 }
>             };
>             
>             worker.start();
> 
> updateLayers and updateLayersOnLoad just iterate through the vector
> turning on/off visibility of the svg element.
> 
> I thought it might be because its using invokeandwait but
> interruptedexception is never thrown.  Could it be because its inside a
> swing worker?
> 
> Any help is much appreciated.  Thanks.
> 
> vyang
> 

-- 
View this message in context: http://www.nabble.com/Update-Manager-Failing-tp25081949p25258154.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Update Manager Failing

Posted by vyang <vy...@apt-cafm.com>.
Thanks for clearing that up Thomas.

vyang


thomas.deweese wrote:
> 
> Hi VYang,
> 
> vyang <vy...@apt-cafm.com> wrote on 09/02/2009 10:01:26 AM:
> 
>> Now with my code below, I'm just wondering if its a good idea/good 
> coding to
>> put updatemanager runnables inside a swing worker.
> 
>    It's fine to have runnables in the swing thread, 
> but you can't wait for them.  The problem is that occasionally 
> the rendering engine needs to get information from Swing, it can
> only do that safely in the Swing thread, so if the swing thread is
> waiting for a runnable to complete and that runnable is waiting for
> the swing thread to become available you get a deadlock.
> 
>> The swingworker is used to display an progress bar only (I believe). 
>> I've read somewhere that the progress bar should be run under 
>> swingutilities runnable.
> 
>     Right updates to swing components must be done in the Swing thread.
> I would suggest that you submit a runnable to the swing thread to update
> the progressbar when your runnable in the UpdateManager thread completed.
> 
>> vyang wrote:
>> > 
>> > SwingWorker worker = new SwingWorker(){
>> >                 public Object construct() {
>> >                     try {
>> > 
>> > finalDrawingPanel.getUpdateManager().getUpdateRunnableQueue().
>> invokeAndWait(new
>> > Runnable(){
> 
>    Here is the problem you can't wait on UpdateManager runnables
> from the Swing Thread.
> 
> 

-- 
View this message in context: http://www.nabble.com/Update-Manager-Failing-tp25081949p25278040.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Update Manager Failing

Posted by th...@kodak.com.
Hi VYang,

vyang <vy...@apt-cafm.com> wrote on 09/02/2009 10:01:26 AM:

> Now with my code below, I'm just wondering if its a good idea/good 
coding to
> put updatemanager runnables inside a swing worker.

   It's fine to have runnables in the swing thread, 
but you can't wait for them.  The problem is that occasionally 
the rendering engine needs to get information from Swing, it can
only do that safely in the Swing thread, so if the swing thread is
waiting for a runnable to complete and that runnable is waiting for
the swing thread to become available you get a deadlock.

> The swingworker is used to display an progress bar only (I believe). 
> I've read somewhere that the progress bar should be run under 
> swingutilities runnable.

    Right updates to swing components must be done in the Swing thread.
I would suggest that you submit a runnable to the swing thread to update
the progressbar when your runnable in the UpdateManager thread completed.

> vyang wrote:
> > 
> > SwingWorker worker = new SwingWorker(){
> >                 public Object construct() {
> >                     try {
> > 
> > finalDrawingPanel.getUpdateManager().getUpdateRunnableQueue().
> invokeAndWait(new
> > Runnable(){

   Here is the problem you can't wait on UpdateManager runnables
from the Swing Thread.