saintbyte / openbmap

Automatically exported from code.google.com/p/openbmap
Other
1 stars 1 forks source link

Another crash (after deleting track). #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start logging.
2. Fire up another application (with Radiobeacon logging in the background) and 
drive to work.
3. Arrive at work, return to Radiobeacon and briefly look at the map.
4. Stop logging.
5. Discover you haven't been anywhere new and delete the log.

What is the expected output? What do you see instead?
After deleting the log, Radiobeacon is forced to close.

What version of the product are you using? On what operating system?
Revision 8e96a4f883b4 on Cyanogenmod 10.1.3-RC2

Please provide any additional information below.
See also issue 27, which deals with a similar (and possibly related) kind of 
crash. Looking at this logcat, though, the issue seems to be caused by 
something else.
Logcat attached, the exception occurs at line 927.

Original issue reported on code.google.com by mich...@vonglasow.com on 16 Sep 2013 at 9:01

Attachments:

GoogleCodeExporter commented 9 years ago
Well this looks like the database got corrupted somehow: there is a wifi table 
entry which doesn't have a corresponding entry in the position table. 

r26f3429381ca adds another check before saving wifis. If no valid location is 
available saving is aborted now.

Nevertheless let's keep an eye on this: you mentioned 'logging in the 
background'. Let's make sure that the root issue isn't related to background 
scanning

Original comment by wish7code on 16 Sep 2013 at 9:47

GoogleCodeExporter commented 9 years ago
Hmmm... I pulled the db from the device and ran

SELECT * FROM wifis WHERE (request_pos_id NOT IN (SELECT _id FROM positions)) 
OR (last_pos_id NOT IN (SELECT _id FROM positions));

and it returned 0 rows.

Could that be a race condition somewhere in the code? E.g. scan has just 
returned but export starts before a new position is received, so the export 
code does not see a valid last_pos_id?

In that case, code like the following might help:

stopLogging() {
   if (isScanRunning()) waitForEndOfScan();
   if (!hasLastPosID(lastScan)) {
       waitForPos(timeout);
   }
}

export() {
    stopLogging();
    //export code here
}

That is: before exporting, stop logging. Make sure the last wifi scan has 
returned and that it has a valid "last position". If not, wait for it, but 
implement a timeout (else the app will hang if GPS is lost just during the 
scan).

Original comment by mich...@vonglasow.com on 19 Sep 2013 at 9:27

GoogleCodeExporter commented 9 years ago
After looking at the log file again, I suddendly realized that the bug was 
fixed without explicit intention :-) 

In the stack trace you see that, the crash is caused by the 
SessionMapObjectsLoader (responsible for drawing current session's wifis on the 
map)

...
09-16 10:16:02.914 E/AndroidRuntime( 9229): at 
org.openbmap.utils.SessionMapObjectsLoader.doInBackground(SessionMapObjectsLoade
r.java:95)
...

Older versions (< rb7ae478d4fea) had a problematic call to 
dbHelper.loadActiveSession().getId(), which caused a NPE as the session was 
actually closed before exporting.

This behaviour was changed when switching to mapsforge 0.4.0 at rb7ae478d4fea . 
At the time I was changing that line of code, I wasn't aware that it's related 
to this issue..

Original comment by wish7code on 19 Sep 2013 at 12:40