locked
Scrollviewer does not render content at offsets larger than 2'096'700 RRS feed

  • Question

  • I think I might have found a possible bug.

    It seems that ScrollViewers start fail to render content at a VerticalOffset of about 2'096'700 or larger.

    When you scroll using a mouse wheel, you will see the content while you scroll. But when the scrolling stops the content goes away.

    I wrote an app that demonstrates this on my computer. It's based on the blank app template, and I simply replaced MainPage.xaml and MainPage.xaml.cs with the following:

    <Page
        x:Class="TestMassiveScrollViewer.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:TestMassiveScrollViewer"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <ScrollViewer x:Name="MainScroller">
                <Canvas Width="800" Height="2110000" x:Name="MainCanvas"/>
            </ScrollViewer>
        </Grid>
    </Page>
    

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;
    using Windows.UI.Xaml.Shapes;
    
    // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
    
    namespace TestMassiveScrollViewer
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
                FillScroller();
                MainScroller.IsTabStop = true;
                MainScroller.KeyDown += MainScroller_KeyDown;
            }
    
            void MainScroller_KeyDown(object sender, KeyRoutedEventArgs e)
            {
                System.Diagnostics.Debug.WriteLine("Scroller at: " + MainScroller.VerticalOffset);
            }
    
            private void FillScroller()
            {
                Rectangle recty = new Rectangle();
                recty.Fill = new SolidColorBrush(Colors.Red);
                recty.Width = 800;
                recty.Height = 400;
                MainCanvas.Children.Add(recty);
                for (int i = 0; i < 30; i++)
                {
                    Rectangle rect = new Rectangle();
                    rect.Fill = new SolidColorBrush(Colors.Red);
                    rect.Width = 800;
                    rect.Height = 400;
                    rect.SetValue(Canvas.TopProperty, 2080000.0 + (i * 1000));
                    MainCanvas.Children.Add(rect);
    
                }
            }
        }
    }
    

    Just grab the scroll bar and scroll to the bottom of the ScrollViewer, then use the mouse wheel to scroll up.

    The red rectangles should be visible while scrolling, but will disappear once the scrolling stops.

    Does anyone have any advice on this?

    Thanks,

    Tomas Hofmann

    Thursday, October 31, 2013 5:48 PM

All replies

  • Hi,

    even if it is a bug. In HD this is a ScrollViewer containing ~2000 Screen pages to scroll. What is the usecase you are seeing here?


    lh


    Thursday, October 31, 2013 7:08 PM
  • Hi Lars,

    My application is a document viewer/editor. It happens when you open a very large document.

    It works fine on Windows 8.0.

    Tomas

    Edit: That's right. I should mention it happens only on Windows 8.1. If I compile the same project for Windows 8.0, it's fine.

    • Edited by T Hofmann Thursday, October 31, 2013 9:09 PM
    Thursday, October 31, 2013 9:08 PM
  • Hi,

    by large do you mean large in pagesize(width and height) or large in number of pages?


    lh

    Friday, November 1, 2013 12:05 PM
  • Hi Lars,

    Large in number of pages. Basically, we let the user chose layout, and then we display the document accordingly. The layout options are basically what the built in Windows PDF reader is like. So, if the user opens a 1000+ pages document and picks continuous layout, we run into this problem.

    Tomas

    Friday, November 1, 2013 5:08 PM
  • Hi,

    am I correct if I assume that you are using an ItemsControl like ListView with a virtualizing panel to render your pages?


    lh

    Friday, November 1, 2013 5:31 PM
  • Hi T Hofmann,

    Welcome here!

    Have your question has been resolved? I have confirmed the issue by testing the sample you shared with us. If you still need to do so, I would like to report this issue to professional engineer.

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 4, 2013 3:16 AM
    Moderator
  • Hi Xiaoliang,

    I still have not found a resolution. If you would report it to a professional engineer, that would be great.

    Thanks,

    Tomas

    Monday, November 4, 2013 5:28 PM
  • I seriously doubt there is a bug here, and even if this was a bug, it's such an edge case that I don't think it's going to get any attention for a long time. 

    XAML has underlying components which have hard limits, and I think that's what this is running into.  2 million 100 thousand pixels is quite a lot, and far exceeds what most apps use.  Hardware resources aren't infinite, so you should rethink your design. 

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, November 4, 2013 8:11 PM
    Moderator
  • Hi Matt Small,

    What about the built in PDF Reader? If you open a 1000+ page document there you have a similar scenario. This is a typical use-case for our customers.

    Also, this wasn't a problem in Windows 8.0. It's not a problem on regular WPF. It also works in previous versions of Silverlight. Therefore, I don't think it's based on XAML. In fact, this is why I think there's a bug, unless of course the underlying system was changed for 8.1 and this is a side-effect.

    Also, if it was a limitation, shouldn't it be documented somewhere?

    Finally, my sample project above isn't particularly resource heavy. It seems to me that a ScrollViewer with a big blank canvas or grid shouldn't really take up that many resources, so as long as you don't try to fill the whole ScrollViewer, but only the parts where the user is currently looking, it shouldn't be that taxing, no matter how much space the content takes up.

    Thanks,

    Tomas

    Tuesday, November 5, 2013 5:05 PM
  • Either I am not able to reproduce this, or I am not understanding something.  I get the same behavior using your code on both Windows 8 and 8.1.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, November 5, 2013 6:59 PM
    Moderator
  • Hi Matt,

    For me, when I use that code to create an app in Windows 8.0 with VS 2012, I do not have the problem.

    But when I create an app in Windows 8.1, using VS2013, I do get the problem.

    Thanks,

    Tomas

    Tuesday, November 5, 2013 10:06 PM
  • Can you reproduce the problem on different hardware?  Also, in detail, what exactly should I be seeing when the problem occurs?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, November 6, 2013 1:51 PM
    Moderator
  • Hi Matt,

    Sorry about the delay. I only had one machine with Windows 8.1 at the time. Also, I had some deadlines, so I forgot about this a bit.

    Anyway, I can now reproduce it on 2 other machines, and with Xiaoliang able to as well, I don't think it's related to hardware.

    The thing you should be seeing is this:

    You can click and drag the scroll bar all the way to the bottom, and you should see the content of the scroll viewer being completely dark (i.e. you won't see any content).

    After this, you can use the scroll wheel to scroll up slowly. You will now see red rectangles while the scroll viewer is actively moving.

    Once you stop scrolling, the content of the scroll viewer should disappear.

    If you scroll to the offset of 2096700, you should see a rectangle cut in half when scrolling stops.

    In short. Any content below 2096700 will not be rendered when the scroll viewer is still. Any content above 2096700 will be rendered all the time.

    Thanks,

    Tomas

    Thursday, November 21, 2013 10:09 PM
  • Hi again,

    This has been sitting for a while and we now have some customers reporting issues when opening documents with 1000+ pages. Basically, they can not view the last pages of the document while in a continuous view mode. I think displaying a large document inside a ScrollViewer is a very valid use case.

    I would like some form of resolution to this:

    Some form of acknowledgement that it is indeed an issue and if and when I can expect a fix to the problem. I'll remind you that this wasn't an issue in Windows 8.0 at all.

    Thanks,

    Tomas Hofmann

    Tuesday, February 11, 2014 8:27 PM
  • Please open a support case for this issue.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, February 12, 2014 2:56 PM
    Moderator
  • Hi Matt,

    Could you clarify what you mean by opening a support case. I looked at various ways to contact Microsoft but I am not sure which is the correct avenue.

    Thanks,

    Tomas Hofmann

    Monday, February 17, 2014 8:19 PM
  • Click this link:
    https://aka.ms/storesupport

    Then on the "Building apps" link.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


    Thursday, February 20, 2014 3:17 PM
    Moderator
  • Hi Tomas,

    As Matt said, this is a known limitation of underlying systems the ScrollViewer sits on top of. It is unlikely this can be changed without repercussions elsewhere. You should be able to virtualized your content so that the visible section is drawn without needing to span so far that this limit comes into play.

    This is what apps like your PDF reader example do (I don't have a large PDF to confirm with, but I can read to the end of Game of Thrones in the Kindle app).

    --Rob

    Thursday, February 20, 2014 4:23 PM
    Moderator