Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [udig-devel] Fwd: [udig-commits] svn - r31024 -udig/trunk/plugins/net.refractions.udig.project/src/net/refractions/udig/project/internal/render/impl



Hello! We have spent a lot of efforts to get rendering working several years
ago for our UDIG-based projects. They are based on the UDIG 1.1.x branch
code with frozen updates from UDIG repository (last update has been done
more then year ago) with lots of local changes and customizations in
net.refractions.udig.* plugins, also in rendering. With Jesse we have fixed
lots of deadlocks and different problems during active development in
rendering code. I can say that we suffered from that instability and when
the rendering has got a more or less stable shape, we stopped to get any
kind of updates from the community. I know many weak places in UDIG and
rendering was the major one during long period of time.
You say that there are problems with rendering in 1.1 -  I am not sure that
this small fix for the particular problem in trunk code base has a relation
to 1.1 branch problems. As I said we use quite old code base of rendering
with our very specific fixes and rendering works perfect for us and our
customers in several projects that are in production during couple of years.
So, I do not know the situation in current 1.1.x branch with rendering. 

During weekend I have checked out trunk code to study about new
improvements, compiled , started UDIG and what a surprise - the deadlock in
rendering after 30 seconds playing with UDIG :) 
Now I explain the use case.
If the shapefile without projection information is loaded to the map, then
both gets DefaultEngineeringCRS.generic2D CRS from the beginning (a kind of
default coordinate reference system based on simply 2D Cartesian CS). The
shapefile itself is in KKJ CRS (EPSG:2393). So I try to change projection of
the  layer with shapefile to EPSG 2393 and UDIG suggests to update also
Map's CRS automatically. I press OK and get a deadlock in RenderJob.run().
It is because  RenderJob.combineRequests() throws underlying exception that
is catched only in RenderJob.run() and requests queue never gets cleared
(requests.clear() is ignored in RenderJob.combineRequests()). This is a peak
of the iceberg.
An exception is originally thrown from CRS.transform(CoordinateOperation,
Envelope) that is called from ReferencedEnvelope.transform(...) that is
called in its own order from RenderJob.combineRequests().
Why is an exception thrown? Because one ReferenceEnvelope from requests
queue of RenderJob (there are several ReferenceEnvelopes in the queue) is in
DefaultEngineeringCRS.Generic_2D crs, but the targetCRS is EPSG:2393 (that
has been set up by the user in UDIG through UI). This combination being
passed to ReferenceEnvelope.transform(targetCRS, , true) gives an underlying
exception. What does DefaultEngineeringCRS.Generic_2D do in the requests
queue? UDIG has a complex multi-threading architecture. Rendering requests
are sent from everywhere with a hope that these requests will be properly
optimized and reduced (combined) that does not happen always. Seems when the
user changes projection of the layer and map the following scenario takes
place:  viewport gets new CRS (EPSG:2393) that causes RenderJob to do its
job with current Layer's CRS (that is Generic2D at this moment). EPSG:2393
is a target CRS but ReferenceEnvelope is in Layer's CRS (Generic_2D). Then
Layer gets new CRS (EPSG:2393) and it is a new request to RenderJob. The
queue of the RenderJob conatins these two requests and it fails to process
the first one (described above).


Sorry for the significant amount of text, I am always trying to explain
problems in details.

Vitali Diatchkov,
Arbonaut Oy,
Finland.

> -----Original Message-----
> From: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx [mailto:udig-devel-
> bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of andrea antonello
> Sent: Monday, December 29, 2008 9:52 AM
> To: ML udig
> Subject: [udig-devel] Fwd: [udig-commits] svn - r31024 -
> udig/trunk/plugins/net.refractions.udig.project/src/net/refractions/udig/p
> roject/internal/render/impl
> 
> Hi Vitalus,
> can you please comment that.
> 
> The udig 1.1 branch these day often doesn't render properly (i.e.
> refresh button has to be triggered a bit too often). I am wondering if
> your fix could be needed/of help also on branch?
> 
> Ciao
> Andrea
> 
> 
> ---------- Forwarded message ----------
> From:  <vitalus@xxxxxxxxxxxxxxxxxxxx>
> Date: Mon, Dec 29, 2008 at 9:25 AM
> Subject: [udig-commits] svn - r31024 -
> udig/trunk/plugins/net.refractions.udig.project/src/net/refractions/udig/p
> roject/internal/render/impl
> To: udig-commits@xxxxxxxxxxxxxxxxxxxxx
> 
> 
> Author: vitalus
> Date: 2008-12-29 00:25:57 -0800 (Mon, 29 Dec 2008)
> New Revision: 31024
> 
> Modified:
> 
> udig/trunk/plugins/net.refractions.udig.project/src/net/refractions/udig/p
> roject/internal/render/impl/RenderJob.java
> Log:
> fix for deadlock in RenderJob because of
> MismatchedReferenceSystemException
> 
> Modified:
> udig/trunk/plugins/net.refractions.udig.project/src/net/refractions/udig/p
> roject/internal/render/impl/RenderJob.java
> ===================================================================
> ---
> udig/trunk/plugins/net.refractions.udig.project/src/net/refractions/udig/p
> roject/internal/render/impl/RenderJob.java
>        2008-12-27 07:07:18 UTC (rev 31023)
> +++
> udig/trunk/plugins/net.refractions.udig.project/src/net/refractions/udig/p
> roject/internal/render/impl/RenderJob.java
>        2008-12-29 08:25:57 UTC (rev 31024)
> @@ -25,6 +25,8 @@
>  import org.eclipse.core.runtime.jobs.Job;
>  import org.geotools.geometry.jts.ReferencedEnvelope;
>  import org.geotools.referencing.CRS;
> +import org.geotools.referencing.crs.DefaultEngineeringCRS;
> +import org.opengis.geometry.MismatchedReferenceSystemException;
>  import org.opengis.referencing.FactoryException;
>  import org.opengis.referencing.crs.CoordinateReferenceSystem;
>  import org.opengis.referencing.operation.TransformException;
> @@ -222,25 +224,38 @@
>     private synchronized ReferencedEnvelope combineRequests() throws
> TransformException, FactoryException {
>         CoordinateReferenceSystem targetCRS =
> getExecutor().getContext().getCRS();
>        ReferencedEnvelope bounds = new ReferencedEnvelope( targetCRS );
> -
> -        for( ReferencedEnvelope env : requests ) {
> -               if( env.isNull() || env.isEmpty() ||
> env.getCoordinateReferenceSystem() == null){
> -                       // these are "invalid" requests and we will skip
> them
> -                       System.out.println("We are skipping an empty
> request");
> -                       continue; // skip!
> -               }
> -                       if(
> !CRS.equalsIgnoreMetadata(env.getCoordinateReferenceSystem(),
> targetCRS) ){
> -                env = env.transform(targetCRS, true);
> -            }
> -            if( bounds.isNull() ){
> -                bounds.init((Envelope)env);
> -            }
> -            else {
> -               bounds.include(env);
> -                // bounds.expandToInclude(env);
> -            }
> -        }
> -        requests.clear();
> +       try{
> +               for( ReferencedEnvelope env : requests ) {
> +                       CoordinateReferenceSystem envCRS =
> env.getCoordinateReferenceSystem();
> +                       if( env.isNull() || env.isEmpty() || envCRS ==
> null){
> +                               // these are "invalid" requests and we
> will skip them
> +                               System.out.println("We are skipping an
> empty request");
> +                               continue; // skip!
> +                       }
> +
> +                       //Vitalus: fix for deadlock in RenderJob
> because of MismatchedReferenceSystemException
> +                       //during transforming from
> DefaultEngineeringCRS.GENERIC_2D
> +                       //to EPSG projection.
> (DefaultEngineeringCRS.GENERIC_2D to EPSG 2393 e.g.)
> +                       if (envCRS != DefaultEngineeringCRS.GENERIC_2D
> +                                       && envCRS !=
> DefaultEngineeringCRS.GENERIC_3D
> +                                       && envCRS !=
> DefaultEngineeringCRS.CARTESIAN_2D
> +                                       && envCRS !=
> DefaultEngineeringCRS.CARTESIAN_3D) {
> +
> +                               if (!CRS.equalsIgnoreMetadata(envCRS,
> targetCRS)) {
> +                                       env = env.transform(targetCRS,
> true);
> +                               }
> +                       }
> +                       if( bounds.isNull() ){
> +                               bounds.init((Envelope)env);
> +                       }
> +                       else {
> +                               bounds.include(env);
> +                               // bounds.expandToInclude(env);
> +                       }
> +               }
> +       }finally{
> +               requests.clear();
> +       }
>         return bounds;
>     }
> 
> 
> _______________________________________________
> udig-commits mailing list
> udig-commits@xxxxxxxxxxxxxxxxxxxxx
> http://lists.refractions.net/mailman/listinfo/udig-commits
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel



Back to the top