在WebView中滚动太快时,通用Windows Phone 8.1应用程序崩溃

时间:2014-08-15 21:09:14

标签: c# xaml visual-studio-2013 windows-phone-8.1 win-universal-app

我正在尝试使用WebView.NavigateToString从字符串加载html内容。页面加载正常但是当我在加载所有内容之前滚动时,应用程序崩溃。 Visual Studio 2013中的调试器未检测到崩溃,而是表示应用程序正常退出。该应用程序的内存使用量也低约50mb。

这是我用于导航到使用WebViewer的页面的代码。

MainPage.cs

public MainPage()
    {
        this.InitializeComponent();

        this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required;
    }


    private void article1_Click(object sender, RoutedEventArgs e)
    {
        Frame.Navigate(typeof(webviewpage),"<!doctype html><html><head><style>img {display: block;margin-left: auto;margin-right: auto;margin-top: 20px; margin-bottom: 20px; width: 100%; height: auto} li { font-size: 2em; } ul { font-size: 25px; } iframe { width: 950; height: 720; display: block;margin-left: auto;margin-right: auto} blockquote { font-size: 3em; font-style:italic; }</style></head><body><p><b>[Vídeo] Os melhores jogos gratuitos para Windows Phone #3</b></p><p style=\"text-align: justify;\">Hoje temos mais uma vez uma dica de 5 games gratuitos para Windows Phone. Se o seu jogo favorito não aparecer nesta seleção, confira os <a href=\"http://www.wpmania.com.br/2014/06/26/video-5-jogos-gratuitos-estilo-plataforma-01/\" target=\"_blank\">outros vídeos</a> pois ele pode estar lá e, caso não esteja, deixe o nome dele nos comentários para que o nosso parceiro Marcos possa fazer o vídeo com a dica para os demais leitores!</p><p style=\"text-align: justify;\"><strong>Sem mais delongas, confira o vídeo abaixo: </strong></p><p><iframe src=\"https://www.youtube.com/embed/rDiL8Z_nz0k\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe></p></body></html>");            
    }

webviewpage.cs

public webviewpage()
    {
        this.InitializeComponent();
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        browser.NavigateToString(e.Parameter.ToString());
    }

webviewpage.xaml

<Page
x:Class="App2.webviewpage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
    <WebView Name="browser"></WebView>
</Grid>

完整的解决方案可以在这里下载:http://speedy.sh/aedfb/App2.rar。使用模拟器与真实设备(在我的情况下为Lumia 520)相比,应用程序崩溃的次数更少。选择一篇文章并尽可能快地向下滚动,应用程序将崩溃。

我的问题是导致应用程序崩溃的原因或是否有人知道如何调试崩溃?即使html不包含图片或iframe,它仍然会崩溃。

1 个答案:

答案 0 :(得分:1)