Error due to closed db connection
See original GitHub issueIssue Type
[x] Bug
Description and/or steps/code to reproduce the problem
Seeing this intermittently on at least API 15 emulators while running connected tests. Relevant logcat excerpt:
W/OsmDroid( 1580): Error getting db stream: /2/1/0 W/OsmDroid( 1580): java.lang.IllegalStateException: database /mnt/sdcard/osmdroid/testzoom4.sqlite (conn# 0) already closed W/OsmDroid( 1580): at android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.java:2082) W/OsmDroid( 1580): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:413) W/OsmDroid( 1580): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:400) W/OsmDroid( 1580): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:79) W/OsmDroid( 1580): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164) W/OsmDroid( 1580): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.DatabaseFileArchive.getImage(DatabaseFileArchive.java:91) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.DatabaseFileArchive.getInputStream(DatabaseFileArchive.java:110) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.MapTileFileArchiveProvider.getInputStream(MapTileFileArchiveProvider.java:195) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.MapTileFileArchiveProvider.access$100(MapTileFileArchiveProvider.java:29) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.MapTileFileArchiveProvider$TileLoader.loadTile(MapTileFileArchiveProvider.java:229) W/OsmDroid( 1580): at org.osmdroid.tileprovider.MapTilePreCache.search(MapTilePreCache.java:99) W/OsmDroid( 1580): at org.osmdroid.tileprovider.MapTilePreCache.access$100(MapTilePreCache.java:26) W/OsmDroid( 1580): at org.osmdroid.tileprovider.MapTilePreCache$1.run(MapTilePreCache.java:37) W/OsmDroid( 1580): at org.osmdroid.util.GarbageCollector$1.run(GarbageCollector.java:31) W/OsmDroid( 1580): at java.lang.Thread.run(Thread.java:856) D/OsmDroid( 1580): TileLoader failed to load tile due to mWriter being null (map shutdown?)
Full logcat: https://api.travis-ci.org/v3/job/396125119/log.txt
Don’t know if this related to the tests itself or might be a concurrency issue related to the new GC functionality. Maybe @monsieurtanuki can take a look?
Environment
If it’s a bug, version(s) of android this affects:
at least API 15
Version of osmdroid the issue relates to:
6.0.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
@cbalster If I remember well, with the new GC feature we never explicitly close the db.
I see in the logs something like “TileLoader failed to load tile due to mWriter being null”.
My first guest: when the test is over we “detach” the fragment and set the
mWriter
tonull
, which somehow implicitly closes the db, while in the same time the GC is running.A simple fix would be to say in the GC: “btw if the db is closed don’t try to do anything” (as it’s pointless - and prone to bug - in that case anyway)
ok well we’ll close for now and reopen if needed