Cordova Windows 10 UWP 应用中的黑屏

Black screen in Cordova Windows 10 UWP app

我正在使用 Cordova 构建一个包含 Ext.js 网络应用程序的 UWP Windows 10 应用程序。

我可以使用 Cordova 和 cordova build windows 以及 Sencha 的系统 sencha app build native 成功构建应用程序。这会在 cordova\platforms\windows\AppPackages 中输出一个文件夹,其中包含一个 .appx 文件,我可以在信任生成的密钥后安装该文件。

问题

安装完成后,如果 "Run when finished" 复选框处于选中状态,应用程序就会加载,我会看到我们的登录屏幕。 如果我按右上角的 X 关闭应用程序,然后从开始菜单重新打开应用程序,我看到的只是黑屏(实际颜色是# 1d1f20)。如果我卸载该应用程序并重新安装,它将再次运行,但只能运行一次。任何随后的关闭和重新打开都会导致黑屏。

如果我取消选中 "run when finished" 复选框,然后手动打开应用程序,我也会看到黑屏。

显示黑屏时,如果我按 F12 打开开发人员工具,然后按 Ctrl 和 R 重新加载,我会看到登录屏幕。没有控制台错误。

如果我在网络浏览器中从 cordova\platforms\windows\www 打开 index.html 文件,然后我会看到登录屏幕。

我尝试将配置添加到与初始屏幕相关的 config.xml,但这对情况没有帮助。

重申一下,该应用程序运行一次(如果立即启动),但随后所有后续启动都只显示黑屏,除非我打开开发者工具并手动重新加载

在Visual Studio

如果我在本地计算机上打开 Visual Studio 和 "Run" 中的解决方案,它会工作并且我会看到登录屏幕。

如果我转到“构建”>“部署解决方案”,它会在我的系统上安装该应用程序,运行 它会正常运行。

这实际上会导致应用程序运行,即使在后续启动时也是如此!!

如果我转到“项目”>“商店”>“创建应用程序包”并创建一个应用程序包,我会遇到同样的黑屏问题(旁注,这会创建一个 .appxbundle 文件而不是 .appx 文件)。

我的系统详细信息:

科尔多瓦配置文件

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.foo.foomobile" version="1.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>FooMobile</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Foo Services
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <preference name="windows-target-version" value="10.0" />
    <preference name="KeepRunning" value="true" />
    <engine name="android" spec="~6.2.3" />
    <engine name="windows" spec="^5.0.0" />
</widget>

我们将不胜感激。

编辑

我用全新的空白 Ext.js 6.5.3 应用程序尝试了 Cordova 构建,并且在首次启动工作和随后启动白屏时也有同样的问题。

编辑 2

Here is a link to the sample app in question

我与 Daniel Twigg 一起解决了这个问题。

问题出在 Sencha Ext JS 微加载器 (bootstrap.js) 中。出于某种原因,将文件动态加载到 microloader 完成的页面中有问题 Windows - 我有一个修改版本的 'bootstrap.js' 文件可以解决问题 - 如果需要请联系我 - 或我可以post这里

marc.gusmano@sencha.com

Sencha 的 Marc 通过提供更新的微加载器帮助我解决了这个问题。代码显示在下面的要点中。

它使用不同的方式加载文件。

https://gist.github.com/djam90/79389bb82696b082b83da701e12373ef

另一种解决方案是通过修改 app.json:

来完全禁用微加载器
"production": {
    "output": {
        "microloader": {
            "enable": false
         }
     }
}