barbeau / gpstest

The #1 open-source Android GNSS/GPS test program
Apache License 2.0
1.73k stars 361 forks source link

Can't manually view log when "Run GNSS in background" is enabled #592

Open tarquinwj opened 2 years ago

tarquinwj commented 2 years ago
  1. In the settings, enable "Run GNSS in background".
  2. In the logging settings, enable logging of location fix data.
  3. Check the log file using file explorer.

Expected behavior The data file should have actual data contents.

Observed behavior The data file either has only headings (about 3 KB) with no data, or is completely empty (0 bytes).

App, Device and Android version:

Main branch Samsung Galaxy S20+ Android 12

barbeau commented 2 years ago

@tarquinwj Thanks for the report! Have you seen this: https://github.com/barbeau/gpstest/blob/master/FAQ.md#when-logging-data-i-only-see-partial-information-in-the-file-like-only-the-header-wheres-my-data

GPSTest buffers log data for performance reasons so if you look at the file using file explorer (on device or connected to computer) you might not see the full file. If you choose the option to "Share" the file (e.g., via email) do you see the whole thing?

tarquinwj commented 2 years ago

Yes, if I share the log I see it. But it does not get any contents if I close the app, or if I disable logging. I presume that is because the service is still running in the background, so it has not exited, even if the app has. As a result, the only way to make it write the file contents seems to be to stop the service (ie. disable logging in the background), or "share" the log. Even so, it seems very inconsistent. Sometimes it does not even write the contents when disabling the service. Once I enabled logging without the service, it then wrote the file it had collected while the service was running.

This is really unpredictable, and meant I lost the data while logging on site - no idea where that went, because it didn't create the file contents at all.

barbeau commented 2 years ago

@tarquinwj Yes, thanks, that makes sense. So we need a way to explicitly stop logging and flush the cache to view the file contents if you're not using the in-app Share mechanism. I'll leave this issue open for this feature. The workaround in the meantime is to use the in-app Share mechanism, which does stop the logging and flush the cache.