Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Crashing on Fence Add when User inside Fence #158

Closed
mhfen opened this issue Jul 18, 2016 · 4 comments
Closed

Android Crashing on Fence Add when User inside Fence #158

mhfen opened this issue Jul 18, 2016 · 4 comments

Comments

@mhfen
Copy link

mhfen commented Jul 18, 2016

Hi Cowbell Team,

I'm using your plugin in an Ionic 2 application. The plugin works fine in iOS. The plugin is crashing the app on Android any time the addOrUpdate method is called to create a Geofence the user is currently within.

Environment Info:

Cordova: 6.2.0
Device: Samsung S6
Android API: 23
Android V: 6
Secondary Device: Nexus 6P
Android API: 23
Android V: 6

Stacktrace

Fatal Exception: java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
       at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:1027)
       at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:664)
       at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:397)
       at android.database.sqlite.SQLiteSession.acquireConnection(SQLiteSession.java:905)
       at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:834)
       at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
       at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:143)
       at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
       at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
       at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258)
       at com.cowbell.cordova.geofence.LocalStorage.getItem(LocalStorage.java:57)
       at com.cowbell.cordova.geofence.GeoNotificationStore.getGeoNotification(GeoNotificationStore.java:20)
       at com.cowbell.cordova.geofence.ReceiveTransitionsIntentService.onHandleIntent(ReceiveTransitionsIntentService.java:69)
       at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:158)
       at android.os.HandlerThread.run(HandlerThread.java:61)

Steps to Reproduce:

  1. Launch cordova application on Android device
  2. Perform an action which triggers the geofence.addOrUpdate method in your code.
  3. Observe the application crash

Thoughts on a solution

It appears from the stacktrace the crash is kicked off in your LocalStorage.java file on line 53. https://github.com/cowbell/cordova-plugin-geofence/blob/master/src/android/LocalStorage.java#L53

@mhfen
Copy link
Author

mhfen commented Jul 19, 2016

I narrowed this crash to happening only when a fence is created when the user is inside that fence. Updating the bug description.

@mhfen mhfen changed the title Android Crashing on addOrUpdate Android Crashing on Fence Add when User inside Fence Jul 19, 2016
@nabinkumarn
Copy link

nabinkumarn commented Dec 6, 2016

Has anyone figured out any solution to this? App is crashing when I add multiple geofence and user is already inside fence.

@bromeostasis
Copy link

Just for reference, it looks like at least @nabinkumarn was able to solve their problem using the suggestion here: #113 (comment)

I'm looking at removing the database.close() instances as I've found a couple of sites that indicate they aren't necessary!

http://touchlabblog.tumblr.com/post/24474750219/single-sqlite-connection
http://stackoverflow.com/questions/6608498/best-place-to-close-database-connection

alburdette619 pushed a commit to alburdette619/Geofencing that referenced this issue Jan 19, 2017
As found in the comments of cowbell#158 databases shouldn't be closed as per this comment from a Google Engineer on the subject. After some testing I have not been able to replicate the issue after removing all instances of database.close()
alburdette619 pushed a commit to alburdette619/Geofencing that referenced this issue Jan 19, 2017
As found in the comments of cowbell#158 databases shouldn't be closed as per this comment from a Google Engineer on the subject. After some testing I have not been able to replicate the issue after removing all instances of database.close()
@tsubik
Copy link
Member

tsubik commented Feb 23, 2017

Fixed in #200

@tsubik tsubik closed this as completed Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants