Windows Phone 7 Web 浏览器更新太慢

发布于 2025-01-04 13:27:15 字数 656 浏览 3 评论 0原文

我有一个带有 XNA 应用程序的 Windows Phone 7 Silverlight。 我还使用了一项使用 javascript 将动态图像呈现到屏幕上的服务。

在 PC 上,JavaScript 流畅且流畅,我可以在图像及其过渡之间顺利跳转。但是,我需要将此功能带到手机上。

截至目前,我已成功使用 Silverlight 中的 Web 浏览器控件来加载 HTML 文件并执行脚本。问题是,一旦应用程序的“动态”部分启动,Web 控件的更新速度就不够快。我没有像 PC 版本那样流畅地滑动动画,而是出现卡顿,类似于游戏中的低 FPS。

所以,我想知道:有什么方法可以提高网络浏览器控件的更新率吗?

我的另一个想法(但没有成功实现)是在应用程序的 XNA 页面中嵌入一个 Web 浏览器并使用 XNA 的更新速率,该速率明显更高(我猜是标准的 60 fps)。但是,Silverlight Web 浏览器控件似乎没有更新渲染功能,并且我找不到将 Web 浏览器嵌入 XNA 应用程序本身的库。

有谁知道如何使用 javascript 使我的动态 HTML 文件流畅流畅地呈现?

编辑: webBrowser.InvalidateArrange() 使用 30 FPS 的计时器似乎加快了浏览器刷新速度,但仍然不稳定。如果我尝试提高 FPS,浏览器就会恢复缓慢。

I have a Windows Phone 7 Silverlight with XNA application.
I'm also using a service which uses javascript to render dynamic images to the screen.

On the PC, the javascript is fluid and smooth, I can jump between images and their transitions smoothly. However, I need to bring this functionality to the phone.

As of right now, I've managed to use the Web Browser control in Silverlight to load my HTML file and execute the script. The problem is that once the "dynamic" part of the application kicks in, the web control doesn't update fast enough. Instead of smooth sliding animations that the PC version results in, I get stutter, similar to having a low FPS in a game.

So, I'm wondering: is there any way to increase the update rate of a web browser control?

Another thought that I've had (but have been unsuccessful at implementing) is to embed a web browser in the XNA page of the application and use XNA's update rate, which is significantly higher (I'm guessing is the standard 60 fps). However, the Silverlight web broweser control doesn't seem to have an update rendering function and the I can't find a library to embed a web browser inside the XNA application itself.

Does anyone have any idea how I can get my dynamic HTML file with javascript to render fluidly and smoothly?

EDIT:
webBrowser.InvalidateArrange() using a Timer at 30 FPS seems to have sped up the browser refresh but it's still jumpy. If I try to increase the FPS, the browser reverts back to being slow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

成熟稳重的好男人 2025-01-11 13:27:15

我猜是标准的 60 fps

标准是 30 FPS

我找不到将 Web 浏览器嵌入 XNA 应用程序本身的库。

我不认为它会得到任何改进。

所以,我想知道:有什么办法可以提高更新率
Web 浏览器控件?

  1. 制作一个在主页上只有一个 Web 浏览器控件的测试应用程序 - 确保除了 Web 控件之外没有任何东西会占用资源。
  2. 检查应用程序的执行情况。如果它足够好,当用户使用“动态”部分时,减少应用程序中的任何其他处理
  3. 如果性能仍然很差,您唯一能做的就是优化 JavaScript 本身
  4. 如果仍然不可接受,则削减该功能或制作一个本机功能。
  5. 利润!

I'm guessing is the standard 60 fps

standard is 30 FPS

I can't find a library to embed a web browser inside the XNA application itself.

I don't think it will get any improvements.

So, I'm wondering: is there any way to increase the update rate of a
web browser control?

  1. Make a test app that has only a web browser control on the main page - make sure that there is nothing that eats the resources except the web control.
  2. Check how the app performs. If it's good enough reduce any other processing in your app while user uses the "dynamic" part
  3. If the performance is still poor, only thing you can do is to optimize javascript itself
  4. If it's still unacceptable cut the feature or make a native one.
  5. Profit!
爱她像谁 2025-01-11 13:27:15

使用设置为 17 毫秒 (60 FPS) 的计时器,我强制浏览器失效,从而导致其重绘。除此之外,我还消除了浏览器不需要重绘的框架。

    DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
    timer.Interval = new TimeSpan(0, 0, 0, 0, 17); // 30 FPS 
    timer.Tick += new EventHandler(timer_Tick);
    timer.Start();

    void timer_Tick(object sender, EventArgs e)
    {
        if (loaded && coded && needToUpdate)
        {
                webBrowser.InvokeScript("setPitch", pitch.ToString());
                webBrowser.InvokeScript("setHeading", heading.ToString());
                Redraw();

                needToUpdate = false;
        }
    }

    void Redraw()
    {
        webBrowser.InvalidateMeasure();
        webBrowser.InvalidateArrange();
        webBrowser.Visibility = System.Windows.Visibility.Visible;
    }

Using a Timer set at 17 milliseconds (60 FPS) I force the invalidation of the browser, which causes it to redraw. In addition to this, I eliminated frames where the browser did not need to be redrawn.

    DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
    timer.Interval = new TimeSpan(0, 0, 0, 0, 17); // 30 FPS 
    timer.Tick += new EventHandler(timer_Tick);
    timer.Start();

    void timer_Tick(object sender, EventArgs e)
    {
        if (loaded && coded && needToUpdate)
        {
                webBrowser.InvokeScript("setPitch", pitch.ToString());
                webBrowser.InvokeScript("setHeading", heading.ToString());
                Redraw();

                needToUpdate = false;
        }
    }

    void Redraw()
    {
        webBrowser.InvalidateMeasure();
        webBrowser.InvalidateArrange();
        webBrowser.Visibility = System.Windows.Visibility.Visible;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文