0

The error is raised randomly in my code. There's so stacktrace available

untitled-2

It's more common when when RaisedPropertyChanged is called such as

    public IImageProvider IForeground
    {
        get { return BlendifierEffect.ForegroundSource; }
        set
        {
            if (BlendifierEffect.ForegroundSource != value)
            {
                BlendifierEffect.ForegroundSource = value;          
                updateImageBlending();
                RaisedPropertyChanged();
            }
        }
    }

So I commented out the RaisedPropertyChanged() method call but it's still being raised once in a while.

The updateImageBlending() is a method which just re-render the effect if any of the blending properties is changed.

    private async void updateImageBlending()
    {
        if (IsRendering)
        {
            return;
        }

        if (SelectedPicture == null)
        {
            return;
        }

        if (SelectedPicture.Index < 3)
        {
            return;
        }

        if (SelectedEffect == null )
        {
            IImageProcessor noEffect = FilterEffects.FirstOrDefault();

            if (noEffect != null)
            {
                RenderResult renderResult = await imageProcessorRenderer.RenderAsync(noEffect, RenderOption.RenderToSoftwareBitmap | RenderOption.RenderAtPreviewSize);
                imageProcessorRenderer.BlendBackground = renderResult.SoftwareBitmap;
                IBackground = new SoftwareBitmapImageSource(imageProcessorRenderer.BlendBackground);
            }
            else
            {
                return;
            }
        }

        Dispatcher.Dispatch(() => { IsRendering = true; });            

        SoftwareBitmap softwareBitmap = null;       
        softwareBitmapRenderer.Size = imageProcessorRenderer.PreviewSize;
        softwareBitmapRenderer.RenderOptions = RenderOptions.Cpu;
        softwareBitmap = await softwareBitmapRenderer.RenderAsync();

        Dispatcher.Dispatch(async () =>
        {
            WriteableBitmapPreview = await convertPreviewToWriteableBitmap(softwareBitmap, null);
        });


        Dispatcher.Dispatch(() => { IsRendering = false; });

    }

softwareBitmapRender takes a BlendEffect and is initialized in the beginning.

if (BlendifierEffect == null)
{
    BlendifierEffect = new BlendEffect();
    BlendifierEffect.GlobalAlpha = 0.5d;
    BlendifierEffect.BlendFunction = BlendFunction.Normal;
    BlendifierEffect.TargetOutputOption = OutputOption.PreserveAspectRatio;
    BlendifierEffect.TargetArea = new Rect(0d, 0d, Scale, Scale);
}
if (softwareBitmapRenderer == null)
{
    softwareBitmapRenderer = new SoftwareBitmapRenderer(BlendifierEffect);
}   

BlendEffect is updated as user change its properties such as

    public IImageProvider Mask
    {
        get { return BlendifierEffect.MaskSource; }
        set
        {
            if (BlendifierEffect.MaskSource != value)
            {
                BlendifierEffect.MaskSource = value;
                updateImageBlending();
            }
        }
    }

What is causing the error and how do I catch it or disable it?

PutraKg
  • 2,226
  • 3
  • 31
  • 60
  • I can't see exactly what might be wrong, however if the exception is coming from the Lumia Imaging SDK then make sure to enable native debugging on your project to see the additional info the SDK gives when throwing an exception. Take a look at: https://msdn.microsoft.com/en-us/library/tdw0c6sf(v=vs.100).aspx (the steps are still the same in Visual Studio 2015) – David Božjak Oct 26 '16 at 12:30
  • @DavidBožjak thanks. I have to download the Symbols from Microsoft server too. Tools>Options>Debugging>Symbols> -- Then Check the box next to Microsoft Symbol Servers. I still can't catch the error but at least it breaks in my code where property changed is raised stating something like break point has been hit (I didn't set the break point though). When I commented out the propertychanged the error is gone. I will update here as I find out more what causing it. – PutraKg Oct 28 '16 at 02:01

0 Answers0