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

after everystart oft streetcomplete the map open in north of italy #2659

Closed
Mannshoch opened this issue Mar 13, 2021 · 13 comments
Closed

after everystart oft streetcomplete the map open in north of italy #2659

Mannshoch opened this issue Mar 13, 2021 · 13 comments
Labels

Comments

@Mannshoch
Copy link

After everystart oft streetcomplete the map open in north of italy (never was there). After that I had to zoom to my location (my TV tablet no GPS connection). If I'm not slow enough doing that #2601 happens'

How to Reproduce
Open the app

Versions affected
31

@Mannshoch Mannshoch added the bug label Mar 13, 2021
@mnalis
Copy link
Member

mnalis commented Mar 13, 2021

perhaps #2311 (comment) is the cause (eg. it might be your device OS, not StreetComplete issue)? Could you try that to see if it helps? (Interestingly, then it was also zooming on Italy)

@matkoniecz matkoniecz added the feedback required more info is needed, issue will be likely closed if it is not provided label Mar 14, 2021
@cyclingcat
Copy link

Same here, but only on my tablet (Samsung Galaxy Tab A (2016), model SM-T585, Android 8.1). I have never observed this behaviour on my two smartphones (Android 9 and the now retired Android 5.1) which I have been using heavily with SC during the past months.

The phenomenon occurs independently of the positioning settings (GPS only, WLAN/mobile only, GPS/WLAN/mobile). And it's always a location south/southwest/southeast of the big northern Italian lakes, but each time a different one! I followed the same procedure as @W-T-Developer in #2311 (comment), this way it's 100% reproducible here.

I will try to find some pattern behind the locations when the SC map opens. First tests show that the zoom factor is always retained after restarting SC, but the position is changed to a (random?) one in the mentioned region.

This phenomenon hasn't attracted my attention until recently, so I'd guess that it was introduced just a few SC versions ago, although I'm not sure because I rarely use SC on my tablet (never outdoors, so just for testing purposes, reproducing issues, making screenshots and so on). I can do further research in this direction if you want me to (= install earlier versions of SC and test them on this device).

The cycling cat

@Helium314
Copy link
Collaborator

Helium314 commented Mar 14, 2021

So far this seems to happen exclusively on tablets, 2 Samsung and 1 unknown. (edit: all Samsung)

Is this only happening in SC, or also in any other application?
I suspect the system may (initially) provide wrong location data. A logger using the passive location provider could help checking whether this is the case (e.g. https://github.com/mendhak/gpslogger/)

@Mannshoch
Copy link
Author

May the poblem is because I do not have a simcard in this Samsung device (SM-T510)
I Only have it on streetcompleete. Problem is also, that streetcompleet do lot located my position. As workaround I temporary open OsmAnd. Than I do not have to zoom around.

@cyclingcat
Copy link

cyclingcat commented Mar 15, 2021

Okay, some more testing and a surprising result:

My tablet computer is mobile radio capable, so I inserted a SIM card into it in order to check if the problem still persists (after all this could be the difference between the tablets and smartphones). No change though.

OSMand~ 3.9.8 (from F-Droid) doesn't show this behaviour: The app also saves map section and zoom factor but restores both correctly if I close the app and restart it.

Now I closed and reopened SC several times, checked each time the geographic locations the map showed afterwards, compared them with the locations the map showed before the app was killed and found a surprising and quite simple pattern:

Let x be the longitude of the location before SC was closed. Then the location the map shows after its restart is:

longitude = x
latitude  = 45.653° N (yes, a constant value!)

(The constant "45.653° N" explains the "northern Italy" observations,)

So we can predict the location the map shows after the restart of SC. Take for example the city of Amsterdam (52.354° N, 4.833° E): If you pan to this city, close the app and reopen it, you can expect the map to be positioned on 45.653° N, 4.833° E, which lies some km to the south of the French city of Lyon. And indeed, this is the case, at least on my device.

@Mannshoch, @mnalis: Try it out - do your tablet computers show the same pattern?

The cycling cat

@matkoniecz
Copy link
Member

Thanks for research!

Which version of SC was tested? Are you testing StreetComplete from F-Droid or from Google Play? (not expecting that answers will help, but I have no good idea what may be happening here)

@W-T-Developer
Copy link

I tried moving the map to poland and ended up in serbia, so it is similar to the behaviour @cyclingcat described.
I used the Playstore version 31.0

@smichel17
Copy link
Member

smichel17 commented Mar 15, 2021

Here's the relevant code:

private fun restoreMapState() {
val camera = loadCameraPosition() ?: return
controller?.setCameraPosition(camera)
}
private fun saveMapState() {
val camera = controller?.cameraPosition ?: return
saveCameraPosition(camera, false)
}
private fun loadCameraPosition(): CameraPosition? {
val prefs = activity?.getPreferences(Activity.MODE_PRIVATE) ?: return null
if (!prefs.containsAll(listOf(PREF_LAT, PREF_LON, PREF_ROTATION, PREF_TILT, PREF_ZOOM))) return null
return CameraPosition(
OsmLatLon(
java.lang.Double.longBitsToDouble(prefs.getLong(PREF_LAT, 0)),
java.lang.Double.longBitsToDouble(prefs.getLong(PREF_LON, 0))
),
prefs.getFloat(PREF_ROTATION, 0f),
prefs.getFloat(PREF_TILT, 0f),
prefs.getFloat(PREF_ZOOM, 0f)
)
}
private fun saveCameraPosition(camera: CameraPosition, saveNow: Boolean) {
activity?.getPreferences(Activity.MODE_PRIVATE)?.edit(saveNow) {
putFloat(PREF_ROTATION, camera.rotation)
putFloat(PREF_TILT, camera.tilt)
putFloat(PREF_ZOOM, camera.zoom)
putLong(PREF_LAT, java.lang.Double.doubleToRawLongBits(camera.position.latitude))
putLong(PREF_LON, java.lang.Double.doubleToRawLongBits(camera.position.longitude))
}
}

I went pretty far down the call stack (to tangram's NativeMap) and everything just passes the same latitude and longitude values down (assumed non-null), no modifications or defaults that I saw. So, best guess at this point is some error saving or loading the prefs. Next step to investigate: What's the value that would make longBitsToDouble generate 45.653° N?

@cyclingcat
Copy link

cyclingcat commented Mar 15, 2021

I tested with the current v31.0 from Play Store. Meanwhile I also tested with v21.0: The phenomenon appears with this version as well, so it's not introduced with some recent version of SC. (Earlier versions don't show a map anymore, it seems that the former map provider has stopped working.)

The cycling cat

@westnordost
Copy link
Member

What's the value that would make longBitsToDouble generate 45.653° N?

What about Double.NaN?

@mnalis
Copy link
Member

mnalis commented Mar 16, 2021

What's the value that would make longBitsToDouble generate 45.653° N?
What about Double.NaN?

@westnordost NaN seems to be correctly encoded/decoded in Kotlin from longBits in accord with IEEE specs.

Example here. (I'm not kotlin programmer, though)

Special values (NaN, inf, ...) for Double should all start with 0x000 or 0x7FF.
45.653 (if it is stored just like that decimal number) is 0x4046D395810624DD, which is nowhere near those ranges.

@cyclingcat unfortunately I do not have a tablet. Can you repeat it if you uninstall and reinstall SC? (in case the upgrade somehow mangles the preferences)?

I've tried what you suggested on spare phone without SIM card running Android 6.0.1 (zooming in to Amsterdam, then exiting SC, starting it again, and doing it several times. I've also tried removing app from cache and starting it again, and even rebooting and starting SC again) and in all cases I get restored exactly to same position - in the middle of Amsterdam where I left it. Which is the same as it does on my primary phone (Android 10).

Could you people having problem try some app which returns raw data for GPS and mobile location (like heregpslocation) so we can see what are the raw values for both GPS and Network reads returned by OS?

Also if anyone happens to have rooted device exhibiting problem, apps like Preferences Manager should be able to read what values exactly are stored in SC preferences.

@cyclingcat
Copy link

Yesterday I had to uninstall SC v31.0 in order to reinstall v21.0 for my test with this old version and got this effect immediately. Nevertheless I just uninstalled SC one more time (meanwhile updated again to v31.0) and reinstalled v31.0 from scratch - no change, the effect is still reproducible.

However, I discovered another odd thing: The described behaviour occurs only if the displayed map is located north of the magic latitude "45.653° N"! If the current map position is located south of it, I can close and reopen SC without the displayed map section being moved! This is also easily reproducible.

This is valid for the northern hemisphere. On the southern hemisphere the effect occurs mirror-inverted: If I pan the map in southerly direction of 45.653° S, the maps jumps to 45.653° S on close/reopen. If I pan the map in northerly direction of 45.653° S, nothing happens upon reopening. (Tested with appropriate locations in Argentina and New Zealand).

The cycling cat

@westnordost
Copy link
Member

Okay, thank you for your research, @cyclingcat . I took a deep look into this too and came to the conclusion, that this is an upstream issue. I created a bug report at tangrams/tangram-es#2249 and provided a video for illustration over at the tangram-es bugtracker. If anyone has anything to add, better do it there.

@riQQ riQQ removed the feedback required more info is needed, issue will be likely closed if it is not provided label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants