ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: Maps and marker clicks on iOS 9

Open MarcBT opened this issue 11 years ago • 24 comments

Type: bug

Platform: ios 9 native hybrid app

Hello,

I am directly copying/pasting a post from ionic forum (http://bit.ly/1G94nkr) as it perfectly describes the issue:

After updating my device to iOS 9, I am having problems with detecting marker click events on maps, which was working perfectly when my device was on iOS 8. The clicks are detected at first, but after some events are performed, clicks no longer fire.

I have tried both Google Maps and Leaflet. While I have not yet found a fully deterministic path to reproducing precisely at what point do the marker clicks no longer fire, I have noticed some patterns:

  • On Google Maps, the first 4-6 clicks are detected, and none thereafter.
  • On Leaflet, all clicks are detected in the first instance of the map view. When moving into another view and back into the map view, the clicks no longer fire. Usually 2 or 3 iterations of cycling out and in of the map view is needed before the clicks stop firing. Double clicks and other events are unaffected. The map is always wrapped with data-tap-disabled="true".

Is anyone else having similar problems?

Here is another post describing the issue (http://bit.ly/1LgshYe) with a codepen available (http://codepen.io/ionic/pen/uzngt).

MarcBT avatar Oct 12 '15 14:10 MarcBT

Hmm, are you adding data-tap-disabled="true" to the map?

mhartington avatar Oct 12 '15 19:10 mhartington

Hi @mhartington, thanks for your answer. Yes, I confirm that we are using data-tap-disabled="true" as indicated in ionic's doc.

The app works perfectly on iOS 8 and Android. Described issue occurs only on iOS 9 devices.

Please note that we are using telerik WKWebview plugin (http://bit.ly/1L8R8PU) to activate WKWebview.

  • We have upgraded it to its latest version but it does not solve the issue.
  • We also tried to remove it and use UIWebview with angular-ios9-uiwebview.patch.js but it does not solve this issue. Thus, this plugin does not seem to cause the issue.

Finally, in addition to codepen exemple in previous's message, we have created a cordova sample app with an index.html file (http://bit.ly/1Pqvh9D) without angular and without ionic dependencies. It loads a simple GMap with some markers and displays alert when click events are triggered. In this case, issue does not occur.

MarcBT avatar Oct 13 '15 07:10 MarcBT

I can confirm this error. It is very strange, because it works for the first clicks. But after some random time, it stops working.

Daveloose avatar Oct 15 '15 13:10 Daveloose

Hi, had the same problem using a leaflet-map. I found out that the error is caused by ionics 'isElementTapDisabled()' function. Its somehow gets stuck in the while loop.

I've replaced it with a small jQuery function and now everything seems to work well.

isElementTapDisabled: function(ele) {

    if (ele && ele.nodeType === 1) {
      var element = ele;

      if ($(element).parents('[data-tap-disabled]').length) {
        return true;    
      }
     /*
      while (element) {
        if ((element.dataset ? element.dataset.tapDisabled : element.getAttribute('data-tap-disabled')) == 'true') {

          return true;
        }
        element = element.parentElement;
      }*/
    }
    return false;
  },

marvinernst avatar Oct 15 '15 14:10 marvinernst

I also have the same issue. I tried the above fix by Ernst and it is working.

pranavrajs avatar Oct 16 '15 11:10 pranavrajs

Hi there, be careful with $parents()'s method from jQuery. It indeed solves the not responding markers/map issue but also breaks the scrollView (at least in my case).

I tried to dig deep around this issue last days. As mentioned by @devilop3rz, the while loop inside isElementTapDisabled is buggy on iOS9.

Problem occurs more precisely with the if condition. Indeed, after few interactions, for a reason I can't understand, the if block is not executed anymore even if its condition is evaluated to true (when data-tap-disabledattribute is detected)...

ionic- 4506-ios9-if-condition-skipped

MarcBT avatar Oct 19 '15 09:10 MarcBT

Moreover, $parents() method does not pass tests as it does not detect a data-tap-disabled attribute present on the touched element.

MarcBT avatar Oct 19 '15 10:10 MarcBT

I've had the same issue using and finally solved it by refactoring the if statement in the 'isElementTapDisabled' function.

if( element.getAttribute('data-tap-disabled') == 'true' || element.dataset.tapDisabled == 'true' ) {

Here's the full 'isElementTapDisabled' function:

  isElementTapDisabled: function(ele) {
    if(ele && ele.nodeType === 1) {
      var element = ele;
      while(element) {
        if( element.getAttribute('data-tap-disabled') == 'true' || element.dataset.tapDisabled == 'true' ) {
          return true;
        }
        element = element.parentElement;
      }
    }
    return false;
  },

If you're curious, here's what the original if statement was:

if( (element.dataset ? element.dataset.tapDisabled : element.getAttribute('data-tap-disabled')) == 'true' ) {

Let me know if this works for anyone!

mcasaje avatar Oct 27 '15 21:10 mcasaje

For your info, we have deployed patch #4538 on our production app and are not experiencing anymore this bug.

@mhartington can you please review eitheir PR #4538 or @mcasaje changes ?

MarcBT avatar Oct 28 '15 12:10 MarcBT

@mcasaje It works for me, Thanks!

jfcisternasm avatar Oct 30 '15 15:10 jfcisternasm

Can you see if the recently merged PR #4589 fixes this for you? Going to close since I believe this is a duplicate solved by that.

mlynch avatar Dec 06 '15 17:12 mlynch

@mlynch. Sure will check and let you know.

MarcBT avatar Dec 07 '15 18:12 MarcBT

Hey this still didn't work for me on Ionic 1.2.1, so I used the patch by mcasaje and it fixed the problem for me on iOS 9.

shamid avatar Jan 07 '16 06:01 shamid

@shamid Thanks for giving feedback on this. I did not have time yet to upgrade and check on my own if ionic 1.2.1 fixed the issue. @mlynch Can you please review @mcasaje solution or PR #4538 and add one of them to the project ? Thanks in advance.

MarcBT avatar Jan 07 '16 07:01 MarcBT

@mcasaje It works for me too, Thanks!

itamair avatar Jan 26 '16 14:01 itamair

@mlynch I can confirm PR #4589 did not fix the issue, but @mcasaje change did

can you reopen the issue?

Thanks

tieum avatar Jan 30 '16 15:01 tieum

same problem here, on ios 9.2 with leaflet 0.7.7 and angular-leaflet-directive + ionic 1.2.4 @mcasaje patch works for me, with this slight change on the if statement

if( element.getAttribute('data-tap-disabled') == 'true' || (element.dataset && element.dataset.tapDisabled == 'true' )) 

bianchimro avatar Feb 06 '16 12:02 bianchimro

same problem on ios 9.3 @mcasaje patch works for me

if( element.getAttribute('data-tap-disabled') == 'true' || (element.dataset && element.dataset.tapDisabled == 'true' ))

hungtrinh avatar Apr 02 '16 14:04 hungtrinh

Same with me as well... the fix provided @mcasaje works fine for me as well... Will this be available in next ionic build?

johntomcy avatar Apr 13 '16 14:04 johntomcy

@mcasaje fix works for me as well. This issue needs to be reopened and the provided fix should be used as the patch.

ghost avatar Apr 27 '16 15:04 ghost