Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova / PGB App freezes after resume

I'm developing a hybrid app with PGB (cli-7.1.0). For a couple of weeks, the app freezes after on iOS (11.3) after brought back to foreground - not every time, but sometimes. The javascript keeps on running and no error is thrown, but no element can be touched anymore. It seems that all event handlers stop working. Scrolling is also not possible anymore.

There is no javascript error nor an error in the device logs, so I'm kinda stuck.

Does anyone have an idea, how to explain that behavior?

Thanks in advance. :)

Solution:

Turns out that iOS 11.3 and js-Fastclick are not compatible right now. There is a fork that solved all problems: https://github.com/lasselaakkonen/fastclick/tree/fix-ios-11-3-event-timestamps

Just in case someone runs into the same problem.

like image 878
floots Avatar asked Apr 19 '18 18:04

floots


1 Answers

I have tested the following two solutions and both of them seem to fix the issue independently.

Solution 1:

Cordova has already fixed this issue in the master, and will be available in their next cordova-ios release v4.6.0. In the meantime, you could patch the changes manually to the latest release version 4.5.4. The change is only in one file so it should be straightforward to just replace the file (CDVViewController.m).

https://github.com/apache/cordova-ios/pull/363/files

You can follow the following steps how to patch the latest release.

  1. Download the latest release version 4.5.4 from github and add the downloaded folder somewhere in your project.

  2. Replace CDVViewController.m with the one in the above pull request

  3. Add the cordova-ios dependency as the external file in your package.json

    "dependencies": {
       ...
       "cordova-ios": "file:PATH/TO/cordova-ios"
       ...
    }
    

Solution 2:

If you are using FastClick, there's a fix to that too under the following pull request. It hasn't been merged yet but seems to fix the issue. So, you can replace your FaskClick.js with the one from the below pull request.

https://github.com/ftlabs/fastclick/pull/550/files

like image 130
Manoj Shrestha Avatar answered Oct 13 '22 09:10

Manoj Shrestha