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

标签 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,它仍然会崩溃。

最佳答案

关于c# - 在 WebView 中滚动太快时,通用 Windows Phone 8.1 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25334247/

相关文章:

c# - 如何在单个 nuget cli 命令中将多个包更新到所需版本?

c# - LINQ to Entities 不支持 Entity Framework 'ArrayIndex'

c# - 如何以及在何处为简单 XAML 窗口中的转换器创建 StaticResource 键?

wpf - 将上下文菜单添加到 TreeView WPF 中的叶节点

wpf - 将多重绑定(bind)放在 xaml 中的一行上

c# - 类型 'Newtonsoft.Json.JsonConvert' 存在于 'Newtonsoft.Json.dll' 和 'NuGetApi2.dll' 中

c# - 统一: How to dynamically attach an unknown script to a GameObject (custom editor)

c++ - strcat访问冲突写位置c++

c++ - Rapidjson 不读取文件

javascript - 将 Web 用户控件添加到页面时,Asp 按钮 onclick 不会触发