petermetz / cordova-plugin-ibeacon

An iBeacon plugin for Phonegap / Cordova 3.x and upwards. Supports both iOS and Android (contributions are welcome)
Apache License 2.0
728 stars 372 forks source link

Android startMonitoringForRegion bogs down the device #176

Open docherty opened 9 years ago

docherty commented 9 years ago

Hi,

I've got an odd thing happening on my Nexus 5 test device. I've created a simple test app that monitors for a beacon. Once I've called $window.cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion) no errors are thrown and everything seems to be OK. However, if I add a simple image to the app interface and set the image source after the monitoring has begun (e.g. in Angular: <img ng-src="{imgUrl}"> and dynamically set imgUrl) it loads really slowly (like the old dial up days...image trickles in from the top). If I comment out the startMonitoringForRegion call then the image loads instantly as I'd expect on a wifi connection. I'm using v3.3.0 of the plugin, Android 5.1.1 and Ionic 1.0.0. My code is really simple and I've posted a Gist with the relevant controller code (thought the code was too long to post here): https://gist.github.com/docherty/8aa0177e63e8f243e1e5

Is there anything obvious anyone can spot in that code or has anyone had/solved! this issue before. Really hoping someone can point me in the right direction...been puzzling over it for a few days! Thanks, James

Ps. using adb + top it looks like the app using ~20% CPU just for monitoring is that typical for Android?

docherty commented 9 years ago

I recorded a video which hopefully shows the problem I'm experiencing in my simple demo app: https://drive.google.com/open?id=0BwfGHmUeg6YxbE1xVlR6b2hHVlU

docherty commented 9 years ago

For anyone interested I've posted a repo with the 'www' directory code for the above demo app. You can get it here: https://github.com/docherty/is.jmd.beacon-test

andersborgabiro commented 8 years ago

When I "jailbroke" (?) my Nexus 7 so it would support BLE I noticed that BLE conflicted severely with Wi-Fi on a radio level. Might be the same here. Hence in my case not software-related. Maybe that was why they chose to not support BLE even though the chip is there. Even on my Sony tablet that's very new I notice a loss in performance over Wi-Fi if there's active BLE communication.

docherty commented 8 years ago

@papasmurph Thanks for that. The device I'm using to test is the Nexus 5 (clean install, as pure as I can keep it!). However, when I turn off bluetooth the app works fine. It's definitely BLE or the way something in the app (monitoring via this plugin) is using BLE. It's really weird because the phone's CPU and memory both seem to be OK while the phone is grinding to a crawl. Very odd...

andersborgabiro commented 8 years ago

Have you tried my Beacon Reader app? On Android it's using the Radius SDK via a plugin. It's rock solid on my Sony tablet. Click once on the title bar to see detected regions, if any (only those listed can be detected). Click once more to see detected beacons (iBeacon only).

https://play.google.com/store/apps/details?id=com.abiro.cliqtagsbeaconreader

andersborgabiro commented 8 years ago

I tried now with the latest version of beacon reader, and it works fine on the Nexus 7 with BLE activated, except it (and the tablet) loses Wi-Fi, and without that the app can't make content lookups. So in my case clearly not app-related, but either hardware or possibly system software ditto, but I suspect radio interference.

andersborgabiro commented 8 years ago

After upgrading to android 5.1.1 (via CyanogenMod) BLE and WiFi work well together, so no interference after all.

RubenMartins commented 8 years ago

Hi @docherty did you find a solutions for this?

I'm experiencing the same issue when start looking for beacons with different models of android and different versions since version 4 to 6 of android. Once I disable the Bluetooth for example the wifi works just fine. This just happens in wifi since if I disable the wifi and use only mobile 4G the app runs smoothly monitoring the Bluetooth for beacons.

halindrome commented 7 years ago

I am seeing this on a Pixel XL running 7.1.1. It seems that ranging is very intensive. Is there a way to limit the frequency of ranging events? Like only call the callback every 500 ms or something?