RadiusNetworks / android-ibeacon-service

An Android library providing APIs to interact with iBeacons
http://developer.radiusnetworks.com/ibeacon/android/index.html
681 stars 244 forks source link

iBeaconManager.getMonitoredRegions() gives back phantom regions #31

Closed jamesfalkner closed 10 years ago

jamesfalkner commented 10 years ago

After several cycles of iBeaconManager.stopMonitoringBeaconsInRegion() and iBeaconManager.startMonitoringBeaconsInRegion() for the same 5 regions, iBeaconManager.getMonitoredRegions() gives back multiples of the same 5 regions.

My concern is this will run the android VM out of memory eventually for a long-running process. I have not yet verified if I am getting multiple callbacks for ranging/monitoring reports, but will check that next.

Here's a log of the action: https://gist.github.com/jamesfalkner/2899e2bbe708d60265bf

At the beginning of the log (line 1), you can see the app is monitoring 5 regions, and it cycles through each one and calls iBeaconManager.stopMonitoringBeaconsInRegion() for each one. So the app should not be monitoring any regions after this. Then on line 51 we start monitoring the same 5 regions with iBeaconManager.startMonitoringBeaconsInRegion(). Then at line 100 the LE scans begin. So all good so far.

Here's where it gets weird: At line 952, we do another set of calls to stop monitoring all regions, but instead of only 5 regions being "currently" monitored, iBeaconManager.getMonitoredRegions() gives back 10 regions (2 copies of the same 5 regions). After we stop monitoring all 10 regions, we do another round of iBeaconManager.startMonitoringBeaconsInRegion(), for the 5 regions we want to monitor. But then, in the next cycle (on line 2002), when we go to stop monitoring everything again, now iBeaconManager.getMonitoredRegions().size() reports 15 regions to stop! Line 3458 shows 20. And so on, it just keeps growing by multiples of 5.

jamesfalkner commented 10 years ago

Verified that my IBeaconConsumer is not getting extra callbacks even though the iBeaconManager may think it's monitoring hundreds of phantom regions and ranging them too. So that's good :)

davidgyoung commented 10 years ago

Yes, it is just a tracking bug. I see the root cause and will fix tomorrow.

Cheers, David On Apr 16, 2014 10:55 PM, "James Falkner" notifications@github.com wrote:

Verified that my IBeaconConsumer is not getting extra callbacks even though the iBeaconManager may think it's monitoring hundreds of phantom regions and ranging them too. So that's good :)

Reply to this email directly or view it on GitHubhttps://github.com/RadiusNetworks/android-ibeacon-service/issues/31#issuecomment-40676018 .

jamesfalkner commented 10 years ago

\o/

davidgyoung commented 10 years ago

I have put in a fix in 81a627df0ce77c9e58b91e20b26725c045bb4913 and rolled a new binary release. Please give the binaries below a shot and let me know if this resolves the issue.

http://s3.amazonaws.com/android-ibeacon-library.radiusnetworks.com/AndroidIBeaconLibrary-0.7.6.2.aar http://s3.amazonaws.com/android-ibeacon-library.radiusnetworks.com/AndroidIBeaconLibrary-0.7.6.2.tar.gz

jamesfalkner commented 10 years ago

You nailed it David, thanks a lot, works perfectly now!