Cordova应用程序在安卓系统上运行,但线程似乎在ios上冻结了;“由于页面加载而重置插件”;
Cordova app working on Android, but thread seems to freeze on ios "Resetting plugins due to page load"
Cordova应用程序在安卓系统上运行,但线程在ios上似乎冻结了。Cordova 6.1版,使用iOS插件4.1.1版。应用程序在Android模拟器和设备上运行良好。
当从XCode应用程序在设备上运行时,似乎加载了。主屏幕看起来很好,但在我按下手机上的主按钮之前,我看不到设备就绪事件之后应该出现的任何console.log语句。然后,前几个函数、连接到SQLite DB等的所有控制台日志语句同时出现。
使用中的插件:
- cordova插件控制台
- cordova sqlite存储器
- flyacts插件条形码扫描仪
然后,我可以再次点击启动器图标并与应用程序交互,但在我再次点击主页按钮之前,控制台中不会显示任何内容。在点击主页按钮让它运行之前,我不能对一个以上的DB事务或对条形码扫描仪的一次调用进行排队。
deviceready之后调用的console.log消息不会出现,但是在应用程序中进行导航的代码会运行,因为通过应用程序进行导航是有效的。似乎只是插件被搁置了。
样本代码:
var app ={
init: function(){
document.addEventListener("deviceready", app.onDeviceReady);
},
onDeviceReady: function(ev){
console.log("device ready"); //this does NOT appear in the console
//add some click listeners to buttons for navigation
//and this code DOES run
console.log("another test message"); //does NOT appear
app.setUpDB();
},
setUpDB: function(){
console.log("setting up DB"); //this does NOT appear in console
//code to open DB and create tables
//this code will not run until after the home button clicked
},
... more functions ...
}
app.init();
console.log("this won't appear before home button click");
点击主页按钮之前控制台中的消息
2016-04-08 08:35:42.900 MeetCute-MadLib[387:141553] Apache Cordova native platform version 4.1.1 is starting.
2016-04-08 08:35:42.903 MeetCute-MadLib[387:141553] Multi-tasking -> Device: YES, App: YES
2016-04-08 08:35:43.000 MeetCute-MadLib[387:141553] Using UIWebView
2016-04-08 08:35:43.005 MeetCute-MadLib[387:141553] [CDVTimer][handleopenurl] 0.510991ms
2016-04-08 08:35:43.012 MeetCute-MadLib[387:141553] [CDVTimer][intentandnavigationfilter] 5.966008ms
2016-04-08 08:35:43.012 MeetCute-MadLib[387:141553] [CDVTimer][gesturehandler] 0.219047ms
2016-04-08 08:35:43.012 MeetCute-MadLib[387:141553] [CDVTimer][TotalPluginStartup] 8.069038ms
2016-04-08 08:35:43.451 MeetCute-MadLib[387:141553] Resetting plugins due to page load.
2016-04-08 08:35:43.807 MeetCute-MadLib[387:141553] Finished load of: file:///var/containers/Bundle/Application/2DC8233D-0BA4-4BE9-8689-53D492193E64/MeetCute-MadLib.app/www/index.html
然后。。。只要点击主页按钮,剩下的就会出现
2016-04-08 08:48:58.538 MeetCute-MadLib[391:143286] Initializing SQLitePlugin
2016-04-08 08:48:58.538 MeetCute-MadLib[391:143286] Detected docs path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Documents
2016-04-08 08:48:58.539 MeetCute-MadLib[391:143286] Detected Library path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Library
2016-04-08 08:48:58.539 MeetCute-MadLib[391:143286] no cloud sync at path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Library/LocalDatabase
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] device is ready
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] tagname a
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] test the sqlitePlugin
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143286] set up DB
2016-04-08 08:48:58.540 MeetCute-MadLib[391:143345] open full db path: /var/mobile/Containers/Data/Application/10EE751F-CE70-449E-800D-817371C9813E/Library/LocalDatabase/DBmeetcute
2016-04-08 08:48:58.584 MeetCute-MadLib[391:143286] THREAD WARNING: ['Console'] took '43.607910' ms. Plugin should use a background thread.
2016-04-08 08:48:58.589 MeetCute-MadLib[391:143286] about to openDatabase
2016-04-08 08:48:58.589 MeetCute-MadLib[391:143286] OPEN database: DBmeetcute
2016-04-08 08:48:58.589 MeetCute-MadLib[391:143286] database already open: DBmeetcute
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] create the tables IF NOT EXISTS
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] new transaction is waiting for open operation
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] fetching profile
2016-04-08 08:48:58.590 MeetCute-MadLib[391:143286] new transaction is waiting for open operation
2016-04-08 08:48:58.596 MeetCute-MadLib[391:143345] Good news: SQLite is thread safe!
2016-04-08 08:48:59.237 MeetCute-MadLib[391:143286] DB opened: DBmeetcute
我能够获得@prof3ssorSt3v3 index.html的副本。CSP不正确,因为它缺少允许JS和本机端通信的gap:
。因此,如果你遇到这样的情况,请在index.html.中检查你的CSP标签
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' data: gap: https://ssl.gstatic.com
'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
相关文章:
- ng类应用于页面加载,表达式不真实
- jPaginate-帮助确定单击了哪个页面
- 将函数应用于页面上的所有链接
- 等待JQuery执行,直到加载了整个页面,中断执行
- Javascript:检测Internet Explorer是否发送了https页面上的混合http消息
- SSL/JS错误破坏了我页面上的表单操作
- 多久以前我加载了一个页面
- 使j查询ajax调用既适用于页面加载,也适用于单击按钮
- 修复了在页面顶部滚动时居中导航的问题
- 固定了与页面其余部分水平滚动的顶部栏
- 折叠表适用于页面上的所有表
- 有没有办法防止TinyMCE自动专注于页面加载
- 淡入比例效果,但适用于页面
- 哪个 jQuery 事件处理程序适用于页面加载
- 添加了视图页面中显示的JS文件,但单击时出现404错误
- 禁用了整个页面的更新进度
- 知道使用javascript打开了哪个页面
- 修复了在页面底部加载时html5标签IE8不工作的问题
- 自2008年以来,更新了在页面中嵌入PDF文件的方法
- __doPostBack()导致了aspx页面中的postback但未调用按钮单击事件