javascript - Async + ClickBusting + Cordova + Android Galaxy S4 = 意外退出

标签 javascript android asynchronous cordova samsung-mobile

This very small Cordova+AngularJS app在运行 Android 4.2.2 的 Galaxy S4 上运行时退出(以“哦,嘿,我崩溃了,我要离开这里!”的方式)。它在我测试过的所有其他设备上运行良好。例如,在运行 Android 4.1.2 的 Galaxy Note II 上就没有问题。

www 目录内容在浏览器中也能正常工作,包括 S4/Android 4.2.2 设备上的浏览器。

所以这个错误似乎只发生在这段代码是:

  • 作为 Cordova 应用程序运行
  • 在运行 Android 4.2.2 的 Galaxy S4 上

复制行为的步骤

  1. 克隆the repo
  2. 使用 Cordova 创建 Android 可执行文件。安装了 cordova 命令行工具和 Android SDK:
    • cordova平台添加android
    • Cordova 构建
  3. 获取生成的 APK 并将其安装在运行 Android 4.2.2 的 Galaxy S4 上。如果您没有,您可以在 http://developer.samsung.com/remotetestlab 免费试用一个。 .
  4. 启动应用。
  5. 触摸应用主屏幕上的文字。
  6. 等待几秒钟,应用程序将退出。

在我测试过的所有其他项目中,它会加载颜色列表内容,这是预期的行为。

综上所述,我的问题是:如何解决此问题以免崩溃?或者我该如何调试它?

相关代码

这些文件都在 repo 中,但是如果你不想点击,就在这里:

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Galaxy S4 + Android 4.2.2 + Cordova Crash</title>

    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
</head>
<body>
    <div id="ng-app" data-ng-app="main">

        <!-- Begin Templates -->
        <script type="text/ng-template" id="main">
            <a ng-click="showList()">On Galaxy S4, touch here, wait a few seconds, and the app will crash.</a>
        </script>

        <script type="text/ng-template" id="list">
        <progress data-ng-show="loading"></progress>
        <ol data-ng-hide="loading">
            <li data-ng-repeat="color in colors">
                {{color.name}}
            </li>
        </ol>
        </script>
        <!-- End Templates -->

        <div data-ng-view=""></div>
    </div>
    <script src="js/angular.js"></script>
    <script src="js/angular-mobile.js"></script>
    <script src="js/modules/main.js"></script>
    <script src="js/modules/list.js"></script>
</body>
</html>

主.js

(function () {
    'use strict';
    angular.module('main', ['ngMobile','list'])
    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider
        .when('/', {templateUrl: 'main', controller: 'mainController'})
        .otherwise({redirectTo: '/'});
    }]).
    controller('mainController', ['$scope', '$location', function ($scope, $location) {
        $scope.showList = function () {
            $location.path('/list');
        };
    }]);
}());

列表.js

(function () {
    'use strict';
    angular.module('list', [])
    .config(['$routeProvider', function ($routeProvider) {
        $routeProvider
        .when('/list', {templateUrl: 'list', controller: 'listController'});
    }])
    .controller(
        'listController',
        ['$scope', '$timeout', function ($scope, $timeout) {
            $scope.loading = true;

            var callback = function () {
                $scope.loading = false;
                $scope.colors = [
                    {name: 'Almost Blue'},
                    {name: 'Kind Of Blue'},
                    {name: 'Totally Not Blue'}
                ];
            };

            // Using $timeout to sort of fake an XHR just to rule out XHR as a cause
            $timeout(callback, 500);
        }]
    );
}());

日志

这显示在 Android 日志中,至少在使用 http://developer.samsung.com/remotetestlab 时是这样。 :

ERROR|10-19 03:39:49.448|6938|6938||CallbackProxy|UPDATE_URL
ASSERT|10-19 03:39:49.493|6938|6953||libc|Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 6953 (WebViewCoreThre)

附加说明

我用 Cordova 3.1.0 试过了。我还尝试使用从 the cordova-android repo 编译的 cordova-3.2.0-dev.jar在提交 28c41294bba746c75beae0ab26a42c8412cc665a(最近提交到 2013 年 10 月 20 日,也就是今天)。行为没有变化——应用程序仍然意外退出。

最佳答案

这是 S4 上三星 Android 4.2.2 Webview 版本中的一个错误。当 S4 更新到 Android 4.3 时,问题就消失了。有可能的解决方法(想到 UA 嗅探,但这让我很难过——但你可以省略 S4/4.2.2 的点击破坏)。但解决方案确实掌握在三星手中。

有关详细信息,请参阅 the relevant issue in the Cordova Android JIRA .

关于javascript - Async + ClickBusting + Cordova + Android Galaxy S4 = 意外退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19459111/

相关文章:

javascript - 异步箭头函数和异步 IIFE 有什么区别?

javascript - Express 中间件中的 Axios 出现错误 - 发送 header 后无法发送 header

javascript - 我应该在 JavaScript 的短 block /函数中定义变量吗?

javascript - 右键单击是 Javascript 事件吗?

javascript - 带有 Grails <content> 标签的 Angularjs

android - 未能解决

javascript - atmospherejs 是否提供任何 API?

Android:未设置电子邮件附件的 MIME 类型

android - 在Android中限制EditText文本长度的最佳方法是什么

c# - 为什么在 WPF UI 线程中执行异步回调