Skip to content
This repository was archived by the owner on Jun 9, 2022. It is now read-only.
This repository was archived by the owner on Jun 9, 2022. It is now read-only.

Strange issue with fastclick and angularJS in cordova/phonegap in iOS with the bind function #466

@pauloya

Description

@pauloya

Hi,
We were getting errors with a callstack that looked like this:

  1. 2016-04-13 15:05:50,911 ERROR - Error: [$rootScope:inprog] $digest already in progress
    http://errors.angularjs.org/1.5.0/$rootScope/inprog?p0=%24digest
    https://aaa.com/web/common/frameworks/angular.js:68:32
    beginPhase@https://aaa.com/web/common/frameworks/angular.js:17178:31
    $apply@https://aaa.com/web/common/frameworks/angular.js:16918:21
    https://aaa.com/web/common/frameworks/angular.js:24551:29
    dispatch@https://aaa.com/web/scripts/frameworks/jquery-2.1.1.min.js:3:6409
    handle@https://aaa.com/web/scripts/frameworks/jquery-2.1.1.min.js:3:3184
    dispatchEvent@[native code]
    sendClick@https://aaa.com/web/scripts/frameworks/fastclick.js:295:30
    **onTouchEnd@https://aaa.com/web/scripts/frameworks/fastclick.js**:589:18
    https://aaa.com/web/scripts/frameworks/fastclick.js:105:43
    send@[native code]
    send@https://aaa.com/web/scripts/frameworks/jquery-2.1.1.min.js:4:14959
    ajax@https://aaa.com/web/scripts/frameworks/jquery-2.1.1.min.js:4:10583
    ajax@https://aaa.com/fins.api/Scripts/jquery.signalR-2.2.0.min.js:8:16074
    ajaxSend@https://aaa.com/fins.api/Scripts/jquery.signalR-2.2.0.min.js:8:18424
    send@https://aaa.com/fins.api/Scripts/jquery.signalR-2.2.0.min.js:8:26147
    send@https://aaa.com/fins.api/Scripts/jquery.signalR-2.2.0.min.js:8:11696
    invoke@https://aaa.com/fins.api/Scripts/jquery.signalR-2.2.0.min.js:8:34506
    subscribeModel@https://aaa.com/fins.api/signalr/hubs:105:62
    subscribeModelWithPromise@https://aaa.com/web/common/services/ModelCacheService.js:99:58
    https://aaa.com/web/common/services/ModelCacheService.js:40:52
    each@https://aaa.com/web/scripts/frameworks/jquery-2.1.1.min.js:2:2938
    https://aaa.com/web/common/services/ModelCacheService.js:39:23
    $emit@https://aaa.com/web/common/frameworks/angular.js:17070:38
    https://aaa.com/web/common/services/SignalRService.js:214:43
    processQueue@https://aaa.com/web/common/frameworks/angular.js:15552:30
    https://aaa.com/web/common/frameworks/angular.js:15568:39
    $eval@https://aaa.com/web/common/frameworks/angular.js:16820:28
    $digest@https://aaa.com/web/common/frameworks/angular.js:16636:36
    $apply@https://aaa.com/web/common/frameworks/angular.js:16928:31
    https://aaa.com/web/common/frameworks/angular.js:18753:42
    completeOutstandingRequest@https://aaa.com/web/common/frameworks/angular.js:5804:15
    https://aaa.com/web/common/frameworks/angular.js:6081:33

The strange thing here is that ajax native send seems to call the onTouchEnd function.
We could replicate the problem by touching the screen while an ajax call was pending (I'm not completely sure of the internals, but we could always replicate by touching the screen at a point where ajax would run).

This didn't happen in the browser, happened only within the cordova app in iOS.

We were able to fix it by renaming the function bind to fcBind. I believe this code somehow hooked event handlers with events it wasn't supposed to.

for (var i = 0, l = methods.length; i < l; i++) {
    context[methods[i]] = bind(context[methods[i]], context);
}

Like I said, renaming the function bind() to fcBind() fixed it.
I thought I would leave this here in case someone else has a similar issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions