cordova-plugin-googlemaps icon indicating copy to clipboard operation
cordova-plugin-googlemaps copied to clipboard

Ionic 2 - Slow DOM manipulation

Open walfridosp opened this issue 9 years ago • 73 comments

First, I would like to thank you guys for the great job you have done with this plugin, no doubts very useful for cordova developers.

My problem: The plugin is taking too long every time a new Element is added to the page, for example this simple example I'm sharing, where I have 3 Tabs (Home, About and Contact).

  • Home: The Map (working perfectly).
  • About: I have a list of 100 Items, if you go to this Tab, you can't scroll the list at all, but if you destroy the map before going to that page (Clicking the button in the Home page), the list will scroll fine.
  • Contact: Just another page.

My question: Is it necessary to destroy The Map every time I'm going to another page?

  • I could live with this, but will be better if I don't have to re-create The Map every time I'm going to this page.

Plugin Version: 2.0.0-beta2-20170625-1805

Testing Device: Samsung SM-C115 Android Version: 4.4.2

cordova plugin list cordova-plugin-console 1.0.5 "Console" cordova-plugin-device 1.1.4 "Device" cordova-plugin-googlemaps 2.0.0-beta2-20170625-1805 "cordova-plugin-googlemaps" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-statusbar 2.2.2 "StatusBar" cordova-plugin-whitelist 1.3.1 "Whitelist" ionic-plugin-keyboard 2.2.1 "Keyboard"

ionic info global packages: @ionic/cli-utils : 1.4.0 Cordova CLI : 6.5.0 Ionic CLI : 3.4.0

local packages: @ionic/app-scripts : 1.3.12 @ionic/cli-plugin-cordova : 1.4.0 @ionic/cli-plugin-ionic-angular : 1.3.1 Cordova Platforms : android 6.1.2 Ionic Framework : ionic-angular 3.5.0

System: Node : v6.9.4 OS : Windows 10 Xcode : not installed ios-deploy : not installed ios-sim : not installed npm : 4.1.2

I have shared the code with you in bitbucket.

Thanks in advance.

walfridosp avatar Jul 02 '17 08:07 walfridosp

Thank you for reporting. Could you tell me your repository name?

wf9a5m75 avatar Jul 02 '17 14:07 wf9a5m75

Thanks for look into this. The name of the repository is gmaps. Here is the link:

https://bitbucket.org/walfridosp/gmaps

walfridosp avatar Jul 02 '17 14:07 walfridosp

I have the same issue. Destroying the map works well and I don't mind doing it. The real problem for me is that I have some buttons in the header of the same page as the map, and the click response is slow (1-2sec).

antoine92190 avatar Jul 02 '17 16:07 antoine92190

@antonie92190 Please share your project, and if you take a video, that would be nice for me.

wf9a5m75 avatar Jul 02 '17 17:07 wf9a5m75

@wf9a5m75 Unfortunately I cannot share my project. I know it might help you understand the issue better but that is not an option, sorry.

However, I tried to reproduce the issue with a brand new ionic project and I cannot reproduce it. I guess the map slows the DOM only when the app has already lot of elements to display.

I shared a video below: map.zip

You can see there is a slow feeling when I switch between the buttons at the top. This latency also exists when I click buttons in the header and when I click on any bottom tab. This latency disappears as soon as I destroy the map.

For the purpose of the video, I removed all logic behind the buttons' click, just to make sure it is actually a DOM issue.

antoine92190 avatar Jul 02 '17 18:07 antoine92190

OK. Thanks for sharing the video. I haven't checked it yet, but I understand you guys situation.

The reason of this is the plugin has to know all HTML element positions and Z-indexes. That's why.

Especially, the ionic framework uses lots of HTML elements. So I can imagine the situation.

I will check the @walfridosp's project later.

wf9a5m75 avatar Jul 02 '17 18:07 wf9a5m75

I can give you another info. On the video you can see that the first page is a list. As Ionic is doing a lot of caching, even when I go to the map, the DOM of the list still exists.

Maybe the map should only consider the visible DOM (and not what is cached). Right now, the plugin seems to also consider the DOM of my list, even when I don't see it.

=> When I empty my list, the map latency issue is much better.

antoine92190 avatar Jul 02 '17 19:07 antoine92190

@walfridosp Could you tell me how to build your project?

wf9a5m75 avatar Jul 02 '17 20:07 wf9a5m75

@wf9a5m75 I added the steps in the README. Let me know if you need anything else.

walfridosp avatar Jul 03 '17 05:07 walfridosp

@walfridosp Thank you for the update. I confirmed your issue. The list page scrolling is very slow. But it seems the polyfills.js takes long time. screen shot 2017-07-04 at 12 50 51 pm

wf9a5m75 avatar Jul 04 '17 19:07 wf9a5m75

I noticed one thing. The list page on Android 4.4 device is really slow, but running on Android 6.0.1 device is faster.

wf9a5m75 avatar Jul 05 '17 17:07 wf9a5m75

I haven't try it in other android device, in iOS is also faster, anyway I would like to support that version of android and above.

I was wondering is it really necessary for the plugin to set a z-index for each element?, maybe adding it to the 'page' is enough, just an idea

walfridosp avatar Jul 05 '17 17:07 walfridosp

@wf9a5m75 I did not have this issue with the 1.4.1 version of your plugin, maybe you can check what is different about how you handle z-index since then?

antoine92190 avatar Jul 05 '17 17:07 antoine92190

I was wondering is it really necessary for the plugin to set a z-index for each element?, maybe adding it to the 'page' is enough, just an idea

Yes, it is really necessary. For example, when you show up a popup dialog on the map, then tap on the dialog, the plugin has to detect the tap is for HTML or map.

wf9a5m75 avatar Jul 05 '17 17:07 wf9a5m75

@antoine92190 The version 1.4.1 monitors only the child elements under the map div. The version 2.0 monitors all HTML elements.

wf9a5m75 avatar Jul 05 '17 17:07 wf9a5m75

Right, I got that from your last comment. But can't you do anything about non visible HTML that ionic is caching?

antoine92190 avatar Jul 05 '17 17:07 antoine92190

I'm testing about that.

wf9a5m75 avatar Jul 05 '17 17:07 wf9a5m75

I updated the plugin code. Please try to reinstall the plugin.

Actually I haven't tested it on Android 4.4 because I don't have the device right now, but it should be fine.

wf9a5m75 avatar Jul 05 '17 20:07 wf9a5m75

That's great!!! will test it right now and will let you know. Thanks!

walfridosp avatar Jul 05 '17 20:07 walfridosp

@wf9a5m75 I have tested it in Android 4.4 and its working smoothly now, no need to destroy The Map, I really appreciate the great work your are doing. Thanks

walfridosp avatar Jul 05 '17 20:07 walfridosp