3

This very small Cordova+AngularJS app exits (in a "oh, hey, I crashed, I'm outta here!" kind of way) when run on a Galaxy S4 running Android 4.2.2. It runs fine on every other device I've tested it on. For example, there is no problem on a Galaxy Note II running Android 4.1.2.

The www directory stuff also works fine in browsers, including browsers on the S4/Android 4.2.2 device.

So the bug only seems to happen when this code is:

  • Run as a Cordova app
  • On a Galaxy S4 running Android 4.2.2

Steps to duplicate behavior

  1. Clone the repo
  2. Create the Android executable using Cordova. With cordova command line tool and Android SDK installed:
    • cordova platform add android
    • cordova build
  3. Take the resulting APK and install it on a Galaxy S4 running Android 4.2.2. If you don't own one, you can test with one for free at http://developer.samsung.com/remotetestlab.
  4. Launch the app.
  5. Touch the text on the app's main screen.
  6. Wait a few seconds and the app will exit.

On everything else I've tested, it loads the color list content, which is the expected behavior.

So all that said, my question is: How do I fix this so it doesn't crash? Or how do I go about debugging this?

Relevant code

These files are all in the repo, but if you don't want to click, here you go:

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>

main.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');
        };
    }]);
}());

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);
        }]
    );
}());

Logs

This shows up in the Android logs, at least when using 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)

Additional Notes

I tried it with Cordova 3.1.0. I also tried it with cordova-3.2.0-dev.jar compiled from the cordova-android repo at commit 28c41294bba746c75beae0ab26a42c8412cc665a (most recent commit to master as of October 20, 2013, which is today). No change in behavior--the app still exits unexpectedly.

Trott
  • 66,479
  • 23
  • 173
  • 212
  • You're probably going to have to dig up an error to get any help on this (who knows though). You may be able to remote debug to get more info https://developers.google.com/chrome-developer-tools/docs/remote-debugging otherwise I would probably start looking for log files. – shaunhusain Oct 18 '13 at 22:24
  • Good point. I added the seemingly relevant things that appear in the Android log to the bottom of the question. As for debugging, I tried debugging, and the callback in the `$timeout()` call never executes. Everything runs as expected except that. Of course, it works fine on other devices. :-/ – Trott Oct 19 '13 at 02:44
  • Based on your log I found some relevant stuff but not sure what you can do about it still? http://comments.gmane.org/gmane.comp.handhelds.phonegap/44629 https://code.google.com/p/android/issues/detail?id=57518 http://stackoverflow.com/questions/14023291/fatal-signal-11-sigsegv-at-0x00000000-code-1-phonegap can you take phonegap out of the equation for test purposes? – shaunhusain Oct 19 '13 at 18:03
  • I removed PhoneGap and compiled with Cordova and the app still crashes. So I updated https://github.com/Trott/s4-angular-phonegap-crash. I could try to remove Cordova, but that's awfully daunting. Still, there's enough there that I can probably file a bug with the Apache Cordova project and, if no one currently working on the project has any ideas or cycles, begin debugging it myself. I anticipate a learning curve... – Trott Oct 20 '13 at 03:30
  • Think you're above my pay grade now... best of luck, let the world know how it goes. I hadn't previously heard of Cordova but it looks pretty awesome, would be nice to be able to use it. – shaunhusain Oct 20 '13 at 03:35

1 Answers1

0

This is a bug in Samsung's version of Android 4.2.2 Webview on the S4. When the S4 gets an update to Android 4.3, the problem goes away. There are probable workarounds (UA sniffing comes to mind, but that makes me sad--but you could omit the clickbusting for the S4/4.2.2). But the solution is really in Samsung's hands.

For details, see the relevant issue in the Cordova Android JIRA.

Trott
  • 66,479
  • 23
  • 173
  • 212