我的 HTML5 Web 应用程序崩溃了,我不知道如何调试
我使用 HTML5 canvas 标签和一点音频编写了一个文字游戏。我在Linux系统上的chrome网络浏览器上开发了该应用程序。最近在测试阶段在 Mac 上的 safari 5.0.3 上尝试,网页卡住了。不仅画布元素被冻结,页面上的交互元素也被冻结。我在开发时有时在 google chrome 上遇到过这个问题,但由于控制台在发生这种情况之前没有抛出任何错误,所以我不太相信它。现在,根据要求,我应该支持 chrome 和 safari,但 safari 上的这种惨淡表现让我感到震惊,我看不出会抛出什么错误,从而可能导致这种情况。更糟糕的是,在我运行 ubuntu 的 2 年旧 MacBook 上,使用这个应用程序的 CPU 使用率达到了 70-80%……我只能可怜那些使用 mac 来操作这个应用程序的人,这无疑是一个更重的操作系统。有人可以帮助我找到一个可以开始的地方,以找出到底是什么导致了这个问题。
我已经在 google chromes 控制台上的这个 web 应用程序上运行了配置文件,并注意到堆 spanshot 值随着游戏的进行而稳定增加,特别是(根)值跳跃了 900 个计数。任何帮助将不胜感激!
谢谢
编辑:我不知道这是否有帮助,但我注意到即使在应用程序无响应后刷新页面,页面也会重新加载,我仍然无法与页面元素交互,但选项卡滚动条继续工作我可以完全看到我的应用程序窗口。因此,总而言之,选项卡停止接受页面内任何类型的用户交互。
编辑2:不。它仍然无法工作...应用程序在双击画布元素时崩溃。控制台也没有抛出任何错误! =/ 我注意到这个问题只存在于 Safari 中!
Edit3:好的,所以我今天进行了一些其他测试。我仅隔离了 HTML5 小部件及其 HTML 数据,并在本地 safari 上运行它以重现该错误。唉,效果很好!所以我尝试在没有 Facebook 集成的情况下从我的服务器玩游戏,结果又正常了!因此,该问题仅出现在 MAC OSX 上的 safari 中,而该小部件则作为 Facebook 应用程序出现在 Facebook 画布上。我很难为这个应用程序想出一个简化的测试用例场景... =/ 更奇怪的是,这个游戏在 Windows 的 Safari 上运行得很好。此外,在该选项卡冻结后,其他选项卡继续响应且运行良好。单击关闭按钮和其他内容后,此选项卡会关闭,但是如果我在冻结后在同一选项卡上加载另一个页面,则页面会加载到选项卡画布中,但我无法与其交互。连 google.com 都没有!所以我确信我的游戏没有错误,但它是一个 Safari 错误...很快就会提交错误报告,感谢所有帮助的人...:)
I have written a word game using HTML5 canvas tag and a little bit of audio. I developed the application on the chrome web browser on a linux system. Recently during the testing phase it was tried on safari 5.0.3 on Mac and the webpage froze. Not just the canvas element, but interactive element on the page froze. I have at some times experienced this problem on google chrome when I was developing but since the console did not throw any error before this happened, I did not give it much credence. Now as per requirements I am supposed to support both chrome and safari but this dismal performance on safari has left me shocked and I cannot see what error can be thrown which might lead to such a situation. Worse yet the CPU usage on using this application peaks to 70-80percent on my 2yr old macbook running ubuntu... I can only but pity the person who uses mac to operate this app, which undoubtedly is a heavier OS. Could someone help me out with a place I can start with to find out what exactly is causing this issue.
I have run profiles on this webapp on google chromes console and noticed that in the heap spanshot value increases steadily with the playing of the game, specifically (root) value which jumps up by 900 counts. Any help would be very appreciated!
Thanks
EDIT: I don't know if this helps, but I have noticed that even on refreshing the page after the app becomes unresponsive the page reloads and I am still not able to interact with the page elements but the tab scroll bar continues to work and I can see my application window completely. So to summaries the tab stops accepting any sort of user interaction inside the page.
Edit2: Nop. It doesn't work still... The app crashes on double click on the canvas element. The console is not throwing any errors either! =/ I have noticed this problem is isolated only to safari!
Edit3: Okay, so I performed some other tests today. I isolated the HTML5 widget and its HTML data only and ran it on safari locally to reproduce the error. Alas it works well! So I tried playing the game from my server without Facebook integration, and it works fine again! So The issue crops up only on safari on MAC OSX, while the widget is on Facebook canvas as a Facebook application. I am very hard-pressed to come up with a reduced test case scenario for this app... =/ It gets weirder, the game works well on safari for windows. Also after the tab freezes the other tabs continue to be responsive and well working. This tab too closes on clicking the close button and stuff, but if I load another page on this same tab after its frozen the page loads in the tab canvas, but I cannot interact with it. Not even google.com! So I am sure there is no bug with my game but its a safari bug... Will soon file a bug report, thanks for all the help people... :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该做的一句话:用尽可能少的代码重现问题。
开始删除应用程序的某些部分,直到发现没有任何内容可以删除,同时仍然保留错误。首先扔掉外部资源(css、图像等),只留下 html 和 javascript。尝试删除音频。尝试删除尽可能多的游戏逻辑。尝试删除所有用户输入代码。
如果这确实是 Safari 本身的错误,而不是您的代码中的错误,那么应该可以创建一个非常的代码示例。在此之前,如果没有任何详细信息或示例,就说“我的网络应用程序无法在 Safari 中运行”,那么您将一事无成。
What you should do, in one sentence: Reproduce the problem with as little code as possible.
Start removing parts of your app until you find nothing that can be removed while still preserving the error. Start by throwing out external resources (css, images, etc) and leave just the html and javascript. Try removing the audio. Try removing as much gaming logic as possible. Try removing all user input code.
If this truly is a bug in Safari itself and not in your code, it should be possible to create a very small code example. Until you have that, saying "my web app doesn't work in safari", without any details or examples, will get you nowhere.