Saturday, January 23, 2010

How Silverlight update got my day OR BitmapCache stopping work with EnableGPUAcceleration when ToolTip shown

After upgrade to SL 3.0.50106 two days ago we got a problem with MultiScaleImage:

when _hover_ mouse on element that has tooltip image in MultiScaleImage control twitches up about 100 –200 pixels, depending on controls layout.

Here is screencast of problem.

MultiScaleImage restore his original view on :

  • resize window
  • programmatic do something with it( for example _msi.ViewPortOrigin = _msi.ViewPortOrigin; )

after day of research we found first that problem can be fixed by removing attribute from MultiScaleImage definition:

CacheMode="BitmapCache"

And build minimalistic layout that reproduce problem:


 <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="80"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel  Orientation="Horizontal" Height="25" >
            <Button Content="Hover me and get OK(NO TOOLTIP)"/>
            <Button Content="Hover me and get BUG(TOOLTIP)" ToolTipService.Placement="Mouse" ToolTipService.ToolTip="TEST TOOLTIP" />
         </StackPanel>
    
        <MultiScaleImage   Grid.Row="1"
                          x:Name="_msi"
                          Width="750" Height="450"
                          Source="dz.xml" CacheMode="BitmapCache"
                            ViewportOrigin="0, -0.07"
                          />
    
    </Grid>

but in a clear project it was not reproduced – it was worked fine with CacheMode. And for that time we was not have any clue why this shit happens. But There were few options where problem can be:

  • How we host Silverlight app on page.
  • Custom script on same page that detects that Silverlight installed.

At first sight on a piece upon me has dawned. We have a GPU Acceleration enabled. Disabling of this option has eliminated a problem.

<param name="EnableGPUAcceleration" value="true"/> 

More precisely problem reproduced when follow combination of options used:


  • CacheMode="BitmapCache"


  • GPU Acceleration used


  • ViewPortOrigin is negative on X or Y. More one, size of ViewPortOrigin influences how much image twitches

So if you use options above, you are in risk group.

By description of update 3.0.50106

it have changes both in GpuAcceleration and in DeepZoom optimization. So seems that was cause a problem


Download test project (3.7 Mb)

No comments:

Post a Comment