草庐IT

javascript - Cordova 应用程序在 Android 上运行,但线程似乎在 ios "Resetting plugins due to page load"上卡住

coder 2024-01-23 原文

Cordova 应用程序在 Android 上运行,但线程似乎在 ios 上卡住。使用 iOS 插件版本 4.1.1 的 Cordova 版本 6.1。应用程序在 Android 模拟器和设备上运行良好。

当从 XCode 应用程序在设备上运行时,似乎已加载。主屏幕显示正常,但我没有看到任何应在设备就绪事件后出现的 console.log 语句,直到我按下手机上的主页按钮。然后,前几个函数的所有控制台日志语句、连接到 SQLite DB 等都会立即出现。

正在使用的插件:

  • cordova-plugin-console
  • cordova-sqlite-存储
  • flyacts-plugin-barcodescanner

然后我可以再次点击启动器图标并与应用程序交互,但在我再次按下主页按钮之前,控制台中不会显示任何内容。在按下主页按钮让它运行之前,我无法排队超过一项数据库事务或一次调用我的条形码扫描仪。

在 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 和 native 端通信的 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 *">

关于javascript - Cordova 应用程序在 Android 上运行,但线程似乎在 ios "Resetting plugins due to page load"上卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36499551/

有关javascript - Cordova 应用程序在 Android 上运行,但线程似乎在 ios "Resetting plugins due to page load"上卡住的更多相关文章

  1. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  2. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  3. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  4. ruby-on-rails - Rails 应用程序之间的通信 - 2

    我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此

  5. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  6. ruby-on-rails - Rails 应用程序中的 Rails : How are you using application_controller. rb 是新手吗? - 2

    刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr

  7. ruby-on-rails - 如何在我的 Rails 应用程序 View 中打印 ruby​​ 变量的内容? - 2

    我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby​​中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R

  8. ruby-on-rails - 迷你测试错误 : "NameError: uninitialized constant" - 2

    我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test

  9. ruby-on-rails - 相关表上的范围为 "WHERE ... LIKE" - 2

    我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que

  10. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

    我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

随机推荐