uDIG
  1. uDIG
  2. UDIG-1641

RenderContextImpl fails when MapViewer not shown yet

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: UDIG 1.2.RC2
    • Fix Version/s: UDIG 1.2.0
    • Component/s: framework
    • Labels:
      None
    • Environment:
      Observed on Ubuntu 9.10 32 bit, but OS-independent

      Description

      RenderContextImpl throws exception when using a MapViewer and (indirectly) calling refesh on the render manager. This only happens when the control (UI) on which the renderer renders has zero dimensions (as it is the case when it hasn't being shown yet).

      The fix is something like check for illegal dimensions before returning the image.

      /**

      • Provide a BufferedImage of the correct size for the map display.
        *
      • @return BufferedImage for use by the Renderer
        */
        public BufferedImage getImage() {

      if (getImageSize().width < 1 || getImageSize().height < 1)

      { return dummyImage; }

      return getImage(getImageSize().width, getImageSize().height);
      }

      Something similar is done in getImage(int,int)

        Activity

        Hide
        Jody Garnett added a comment -
        Sounds good do you want to apply the patch? ImageSize may also have an isEmpty method to check for 0 width.
        Show
        Jody Garnett added a comment - Sounds good do you want to apply the patch? ImageSize may also have an isEmpty method to check for 0 width.
        Hide
        Ugo Taddei added a comment -
        I'm using this patch and it's all right. Haven't got to test the uDig application (absolute lack of time) but shouldn't break anything. Also, I cannot explicitely check for image sizes, because this (the rendering) is triggered by some addLayer call.
        Show
        Ugo Taddei added a comment - I'm using this patch and it's all right. Haven't got to test the uDig application (absolute lack of time) but shouldn't break anything. Also, I cannot explicitely check for image sizes, because this (the rendering) is triggered by some addLayer call.
        Hide
        Jody Garnett added a comment -
        I already see the following in getImage:

        if (width < 1 || height < 1)
                    return dummyImage;

        So the idea of returning a dummy image is already in use; any other stuffestions? Perhaps you could list the exception for us?
        Show
        Jody Garnett added a comment - I already see the following in getImage: if (width < 1 || height < 1)             return dummyImage; So the idea of returning a dummy image is already in use; any other stuffestions? Perhaps you could list the exception for us?
        Hide
        Jody Garnett added a comment -
        Updated the bug report title to be more descriptive; so to proceed we need you to attach the stack trace or provide an example view or something that shows the problem.
        Show
        Jody Garnett added a comment - Updated the bug report title to be more descriptive; so to proceed we need you to attach the stack trace or provide an example view or something that shows the problem.
        Jody Garnett made changes -
        Field Original Value New Value
        Summary RenderContextImpl throws exception RenderContextImpl fails when MapViewer not shown yet
        Hide
        Jody Garnett added a comment -
        Okay I went over the code and the only thing I found to protect against is a NPE; see commit on trunk as of -r31753. Reopen this issue if needed.
        Show
        Jody Garnett added a comment - Okay I went over the code and the only thing I found to protect against is a NPE; see commit on trunk as of -r31753. Reopen this issue if needed.
        Jody Garnett made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s UDIG 1.2.RC3 [ 16441 ]
        Resolution Fixed [ 1 ]
        Hide
        Ugo Taddei added a comment -
        Here is the stack trace:

        java.lang.IllegalArgumentException: Width (0) and height (0) must be > 0
        at java.awt.image.SampleModel.<init>(SampleModel.java:108)
        at java.awt.image.ComponentSampleModel.<init>(ComponentSampleModel.java:128)
        at java.awt.image.PixelInterleavedSampleModel.<init>(PixelInterleavedSampleModel.java:69)
        at java.awt.image.Raster.createInterleavedRaster(Raster.java:638)
        at java.awt.image.Raster.createInterleavedRaster(Raster.java:265)
        at java.awt.image.BufferedImage.<init>(BufferedImage.java:367)
        at net.refractions.udig.project.ui.internal.RenderManagerDynamic$3.getImage(RenderManagerDynamic.java:465)
        at net.refractions.udig.project.internal.render.impl.RenderContextImpl.getImage(RenderContextImpl.java:148)
        at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:316)
        at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:296)
        at net.refractions.udig.project.internal.render.impl.RenderExecutorComposite$CompositeRendererListener.stateChanged(RenderExecutorComposite.java:212)
        at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl$RendererListener.notifyChanged(RenderExecutorImpl.java:164)
        at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280)
        at net.refractions.udig.project.internal.render.impl.RendererImpl.setState(RendererImpl.java:169)
        at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl$3.renderDone(CompositeRendererImpl.java:161)
        at net.refractions.udig.project.internal.render.RenderListenerAdapter.notifyChanged(RenderListenerAdapter.java:74)
        at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280)
        at net.refractions.udig.project.internal.render.impl.RendererImpl.setState(RendererImpl.java:169)
        at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl.setState(RenderExecutorImpl.java:285)
        at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl$RendererListener.stateChanged(RenderExecutorImpl.java:171)
        at net.refractions.udig.project.internal.render.impl.RenderExecutorMultiLayer$MultiLayerRendererListener.stateChanged(RenderExecutorMultiLayer.java:118)
        at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl$RendererListener.notifyChanged(RenderExecutorImpl.java:164)
        at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280)
        at net.refractions.udig.project.internal.render.impl.RendererImpl.setState(RendererImpl.java:169)
        at net.refractions.udig.project.internal.render.impl.RenderJob.postRendering(RenderJob.java:190)
        at net.refractions.udig.project.internal.render.impl.RenderJob.run(RenderJob.java:214)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
        Show
        Ugo Taddei added a comment - Here is the stack trace: java.lang.IllegalArgumentException: Width (0) and height (0) must be > 0 at java.awt.image.SampleModel.<init>(SampleModel.java:108) at java.awt.image.ComponentSampleModel.<init>(ComponentSampleModel.java:128) at java.awt.image.PixelInterleavedSampleModel.<init>(PixelInterleavedSampleModel.java:69) at java.awt.image.Raster.createInterleavedRaster(Raster.java:638) at java.awt.image.Raster.createInterleavedRaster(Raster.java:265) at java.awt.image.BufferedImage.<init>(BufferedImage.java:367) at net.refractions.udig.project.ui.internal.RenderManagerDynamic$3.getImage(RenderManagerDynamic.java:465) at net.refractions.udig.project.internal.render.impl.RenderContextImpl.getImage(RenderContextImpl.java:148) at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:316) at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:296) at net.refractions.udig.project.internal.render.impl.RenderExecutorComposite$CompositeRendererListener.stateChanged(RenderExecutorComposite.java:212) at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl$RendererListener.notifyChanged(RenderExecutorImpl.java:164) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280) at net.refractions.udig.project.internal.render.impl.RendererImpl.setState(RendererImpl.java:169) at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl$3.renderDone(CompositeRendererImpl.java:161) at net.refractions.udig.project.internal.render.RenderListenerAdapter.notifyChanged(RenderListenerAdapter.java:74) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280) at net.refractions.udig.project.internal.render.impl.RendererImpl.setState(RendererImpl.java:169) at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl.setState(RenderExecutorImpl.java:285) at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl$RendererListener.stateChanged(RenderExecutorImpl.java:171) at net.refractions.udig.project.internal.render.impl.RenderExecutorMultiLayer$MultiLayerRendererListener.stateChanged(RenderExecutorMultiLayer.java:118) at net.refractions.udig.project.internal.render.impl.RenderExecutorImpl$RendererListener.notifyChanged(RenderExecutorImpl.java:164) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280) at net.refractions.udig.project.internal.render.impl.RendererImpl.setState(RendererImpl.java:169) at net.refractions.udig.project.internal.render.impl.RenderJob.postRendering(RenderJob.java:190) at net.refractions.udig.project.internal.render.impl.RenderJob.run(RenderJob.java:214) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
        Hide
        Jody Garnett added a comment -
        Can you test against http://snapshots.dist.codehaus.org/udig/udig1.2-RC3/ and let me know if this issue is fixed for you or if it needs to be reopened?
        Show
        Jody Garnett added a comment - Can you test against http://snapshots.dist.codehaus.org/udig/udig1.2-RC3/ and let me know if this issue is fixed for you or if it needs to be reopened?
        Hide
        Ugo Taddei added a comment -
        Fix in RenderContextImpl should be

        public BufferedImage getImage() {
                Dimension size = getImageSize();
                if( size == null || size.width < 1 || size.height <1 ){
                    return dummyImage; // dummy image
                }
                return getImage(size.width, size.height); // will create if needed
            }

        rather than

        public BufferedImage getImage() {
                Dimension size = getImageSize();
                if( size == null || size.width < 1 || size.height <1 ){
                    return null; // dummy image
                }
                return getImage(size.width, size.height); // will create if needed
            }

        getImage is returning null (probaly a typo, as the comment is OK).

        The code generated a

        java.lang.NullPointerException
        at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:320)
        at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:296)
        at net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.updateImage(RenderManagerAdapters.java:193)
        at net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.zorderChanged(RenderManagerAdapters.java:154)
        at net.refractions.udig.project.internal.ContextModelListenerAdapter.notifyChanged(ContextModelListenerAdapter.java:97)
        at net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.notifyChanged(RenderManagerAdapters.java:142)
        at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280)
        at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:255)
        at org.eclipse.emf.common.notify.impl.NotifyingListImpl.move(NotifyingListImpl.java:1309)
        at net.refractions.udig.project.internal.impl.LayerImpl.setZorder(LayerImpl.java:467)
        at de.fraunhofer.iais.kd.********
        Show
        Ugo Taddei added a comment - Fix in RenderContextImpl should be public BufferedImage getImage() {         Dimension size = getImageSize();         if( size == null || size.width < 1 || size.height <1 ){             return dummyImage; // dummy image         }         return getImage(size.width, size.height); // will create if needed     } rather than public BufferedImage getImage() {         Dimension size = getImageSize();         if( size == null || size.width < 1 || size.height <1 ){             return null; // dummy image         }         return getImage(size.width, size.height); // will create if needed     } getImage is returning null (probaly a typo, as the comment is OK). The code generated a java.lang.NullPointerException at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:320) at net.refractions.udig.project.internal.render.impl.CompositeRendererImpl.refreshImage(CompositeRendererImpl.java:296) at net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.updateImage(RenderManagerAdapters.java:193) at net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.zorderChanged(RenderManagerAdapters.java:154) at net.refractions.udig.project.internal.ContextModelListenerAdapter.notifyChanged(ContextModelListenerAdapter.java:97) at net.refractions.udig.project.ui.internal.RenderManagerAdapters$3.notifyChanged(RenderManagerAdapters.java:142) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280) at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(EcoreEList.java:255) at org.eclipse.emf.common.notify.impl.NotifyingListImpl.move(NotifyingListImpl.java:1309) at net.refractions.udig.project.internal.impl.LayerImpl.setZorder(LayerImpl.java:467) at de.fraunhofer.iais.kd.********
        Ugo Taddei made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Hide
        Jody Garnett added a comment -
        Sigh; messed that one up. Fix applied to trunk.
        Show
        Jody Garnett added a comment - Sigh; messed that one up. Fix applied to trunk.
        Jody Garnett made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Fix Version/s UDIG 1.2.0 [ 16264 ]
        Fix Version/s UDIG 1.2.RC3 [ 16441 ]
        Resolution Fixed [ 1 ]
        Jody Garnett made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Jody Garnett
            Reporter:
            Ugo Taddei
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: