Closed Helium314 closed 2 weeks ago
Uh, oh, that's right, I didn't notice that it is even inconsistent within the app. For markers, the text is below, for overlays, to the right. But I think I know the reason why I did that and it doesn't apply for MapLibre anymore, so I can remove that. (Because the left-alignment also causes issues for the address overlay)
I'll be looking into the location component
I pushed the changes into a branch... overall, I am not that convinced that we should use it. Reasons:
bool
to show it or not. Should iOS and Android thingies work the same, the code must be in the app(not done with it. I will try to get smooth animation of position + maybe even accuracy circle working. Then, I'll consider moving the "follow location" and "navigation mode" stuff into that component.)
I tried the LocationComponent a few times, but the accuracy circle behavior is really weird. Smooth animations for the current (non-MapLibre) style is all that is missing I think.
(I finally had a little time to build the maplibre test app, hopefully it will work on my phone at some point)
@westnordost I'll be able to test on a 64 bit capable phone starting tomorrow, so I can finally continue here... (any I'll have more time than in the past 2 weeks)
Nice!
(Which phone? Are you planning to change your EDC phone?)
Note that (in regards to the description text of this PR) quite a few things, especially visual ones, have been solved or cleared up. We won't use the compass, attribution from uiSettings and we won't use the locationCompoment.
Note that (in regards to the description text of this PR) quite a few things, especially visual ones, have been solved or cleared up. We won't use the compass, attribution from uiSettings and we won't use the locationCompoment.
I'll check and update the initial post (if you want you can also edit / add / remove stuff).
Which phone? Are you planning to change your EDC phone?
I got a Galaxy A3 (2017), which is the smallest Android phone with OLED display that's clearly better than my S4 Mini VE. If I find it acceptable I might actually use it as EDC, not sure yet.
Good thing: it finally works (no crash) Not so good thing: zooming out with quests displayed is still somewhat janky, with tangram it's smoother even on the original S4 Mini Other not so good thing: quest icons and pins are misaligned in second tutorial screen
Well, there are two things that will likely make it smoother: quest clustering + removal of quest dots and CustomGeometrySource you have been working on.
Because:
Galaxy A3 looks still reasonably small. The next more modern phones when OLED is a must would already be my Samsung s10e (2019) and the Sony Xperias with the stupid naming scheme, both quite a bit larger.
Anyway, next thing I intend to do on this PR is to maybe move the follow-position and navigation mode stuff also in the location component (to mirror the capabilities of the locationComponent). If not, then make it an own component. And then, consider merging the MapFragment, LocationAwareMapFragment and MainMapFragment into one. My original reason for this separation was 1. keep the files small, 2. maybe there will be a second map somewhere in the app that should e.g. not display the quests but other things (e.g. download dialog, splitting way etc..). Reason 1 should rather be solved with utility / extension classes and functions (like these *Components) plus viewmodels and reason 2 never came to pass and I find it unrealistic that it would ever. A strong reason for merging the three is https://github.com/Helium314/SCEE/pull/516#issuecomment-2008437828
I will likely continue next week.
Do you intend to continue soon? I am currently a digging through all fragments and restructuring them with ViewModels, so I can imagine that I am generating quite some (at least: merging) work for you. I am not changing anything closely related to the map, of course, taking into account this PR.
Galaxy A3 looks still reasonably small. The next more modern phones when OLED is a must would already be my Samsung s10e (2019) and the Sony Xperias with the stupid naming scheme, both quite a bit larger.
Still not sure whether it will be EDC, it feels too large and slippery (the rough plastic back on the black S4 Mini is really nice).
Do you intend to continue soon?
I don't have much time, and currently learning a lot of new stuff on my job which can be a little exhausting...
I'll try working on polishing the offline stuff, which is mostly MapTilesDownloader
. So I don't think there will be many merge conflicts here.
Btw should be merge the current master? Or do it only in the end?
The slippery glass back of my s10e also bothers me, ultimately I bought a silicon casing because of this.
Oh yeah, that can be exhausting.
Btw should be merge the current master? Or do it only in the end?
I think that makes sense. I was also thinking whether it would be better to rebase this PR on top of upstream master, not sure how well a merge from SCEE to StreetComplete would work, I don't have any experience with this.
Merging master should work normally. The master
branch in this repo is currently up to date with SC.
On the offline tiles:
Should we guarantee they are stored for ApplicationData.DELETE_OLD_DATA_AFTER
(14 days), so there are always tiles when there is downloaded map data? This requires keeping track of downloaded regions, but that should be simple. Using this options means that size of map tile database may exceed the value in MAP_TILECACHE_IN_MB
pref.
Or should we just download the tiles and allow deletion if the cache size is exceeded? I guess the longest unused tiles will go first, as there is an access date for each tile in the offline db (plus it makes sense).
I removed the tile download info logging, it will now only report the number and size of the tiles in the downloaded region, but not which / how many of them were already cached before download. No idea how to get this data from MapLibre, and I think it's not that important.
There is some setOfflineMapboxTileCountLimit
option, which should invoke a callback when too many tiles are downloaded (and possibly will cancel the download, documentation is not clear). Anyway, I tried setting it to a very low number and still the callback wasn't triggered. Maybe we could ignore the callback, or set the tile count limit to a really high number to avoid unexpected issues later.
Should we guarantee they are stored for ApplicationData.DELETE_OLD_DATA_AFTER (14 days), so there are always tiles when there is downloaded map data? This requires keeping track of downloaded regions, but that should be simple. Using this options means that size of map tile database may exceed the value in MAP_TILECACHE_IN_MB pref.
The technique is different, so the implementation can also be different. So, I would say, whatever is most straightforward to implement. If I had to choose, I would think it more important that the old data is only deleted after 14 days than that there is a MAP_TILECACHE_IN_MB setting at all(, or be respected closely).
(The MAP_TILECACHE_IN_MB setting has always been somewhat... hmm... intransparent/useless to users because users have no idea how big in MB a given area is. I would not miss this setting. The setting has existed before I implemented offline map tiles download.)
Then I'll add this part to a todo section on top of the PR. I will need to store offline region id and dowloaded timestamp in a new table, and I think this is best to do just before merging the PR (and after merging master into this branch).
I tested how much time it takes to transform the Pin
s and StyledElement
s to Geojson Features. The time it takes is negligible (0-4ms in my tests), so no need for any optimization that would cache the Features or anything like that.
I also moved the creation of the preset icon bitmaps (~400ms) and pin icon bitmaps (~800ms) into the Preloader, so it is only done once and immediately on startup in the background, which should speed up the time until the map is fully visible by one second or so. Also, I fixed a bug where the location dot would only appear after the next GPS update occured (5s), which made it look like it takes that long until the map is fully loaded. So, especially on startup, the map should feel a bit faster.
I will write an own todo list here, as the starting comment has a lot of things that are not actually todos, too, and I am not sure with whether you are okay with me removing them. So, let's do a complete todo list in this comment.
Feel free to update this comment to either add todos or remove todos that have been solved
CustomGeometrySource
(draft started by @Helium314)I am not sure with whether you are okay with me removing them
Would be ok for things that are outdated or we don't want to touch anyway. I'll copy it to the top post.
adjust the fling behavior
Thanks for the reminder, now I finally can try it!
I'll look at the oneway arrows in the map style next, plus look into the issues with the camera. I'll leave the offline tiles and CustomGeometrySource stuff to you. Regarding clustering, I guess that should come after the refactor of the QuestPinManager.
And regarding merge from master, ... uh ... maybe I do that after, unless you think it makes more sense if you do it.
And regarding merge from master, ... uh ... maybe I do that after, unless you think it makes more sense if you do it.
Probably better if you do it, as you have better overview about what is changed and where MapLibre things should go if they need to be moved
Offline tiles should be fine, only need to test whether
I think I will remove the local streetcomplete.json file. As long as for offline download, the streetcomplete.json needs to be pulled anyway from the URL, it seems to me it is only overhead to also have it locally.
Any resources used, like sprites (=oneway arrows) or glyphs (fonts) are also pulled from remote.
Would you agree?
The only drawback I can think of is that theme switch may have issues when the new style is not yet downloaded. Otherwise I think it's fine.
I'll next review the code so (except the areas I know are still worked on) and fix/change anything I notice along the way or add to the todos.
Maybe something to look into: on first download after install I didn't get any quests to show up, they came only after restarting the app. Further downloads were working, and I could not reproduce it by clearing app storage.
Putting the MapTilesDownloader
in the cleaner was a bad idea... init
calls MapLibre.getInstance(context)
, which only works from UI thread, so it crashes when done from cleaner worker (possibly works when SC is still in recents).
Since MapLibre.getInstance(context)
needs to be called before accessing the OfflineManager
(for cleaning old regions / tiles), we need some alternative.
And another (minor) issue: After starting I don't see the undo button, even when there are not uploaded quests. I need to solve a new quest for it to appear.
Hm, but the MapTilesDownloader is also the class that takes care of managing the data downloaded for offline. I'll look into it.
How do you detect a crash in the CleanerWorker when the app itself does not run?
I noticed old crash messages in Android Studio logcat view
I made it so that exceptions are just caught and logged. If it is not executed on the main thread, and that is a prerequisite, there is not much we can do. (I also, unrelated to the fix, because all those callbacks were difficult to read, added extension functions that are suspending version of the original API so that the code can be written simply from top to bottom)
And another (minor) issue: After starting I don't see the undo button, even when there are not uploaded quests. I need to solve a new quest for it to appear.
Already fixed on streetcomplete master
Maybe something to look into: on first download after install I didn't get any quests to show up, they came only after restarting the app. Further downloads were working, and I could not reproduce it by clearing app storage.
Its seems to be related to the style download, sometimes happened when starting while the phone is offline. But I guess it's fixed already by having the styles offline again.
Oh, cool
When testing for the SDF icons I noticed that overlay icons seems to be blocked by quest pins, is this an intentional change?
No. They just should block each other below a certain zoom level (they should not overlap that early). However, I think it is not possible to specify that icons in the same layer should block each other but disregard any icons in any other layers?
@westnordost what do you think about a new PR in the correct place, i.e. to SC? When I created this PR I wasn't sure whether this branch would be scrapped or evolve into the "real thing", and further I wanted to avoid attention (other people discussing / commenting here).
Now the PR is rather close to being done, with only a short todo list.
🤷 I don't see why not (but I also don't see why)
fix move node functionality is somewhat broken (wrong positions) - something to do with padding
From my testing:
I am fixing it right now. Sorry, I should have posted here that I am working on it.
offline tiles download: test whether offline region behavior works as intended (deleting and not exceeding size)
Part 1 tested: The initial offline db is about 15 MB (mostly glyphs for the style). After scrolling a lot, size was 27 MB. Then setting cache size to 10 MB shrank the db to 25 MB, so that's working.
Part 2 missing: clearing offline regions. I reduced the time until the regions get removed, lets see how the db has changed tomorow.
I found some more issues which I believe must also exist for current master, related to changing between portrait and landscape mode while a form is open. However, I don't want to care about this too much because pending is a big refactor to use viewmodels and then jetpack compose anyway.
I just got a "StreetComplete keeps stopping" message by the OS, after having removed SC from recents around 18:50, and not using the phone after that until 20:34. Looks like it's related to the cleaner.
Starting SC again worked normally. I'll leave SC running in background, hoping that the cleaner will run.
The last one looks like a MapLibre something-something. Crash-dumps will hopefully become more useful once https://github.com/maplibre/maplibre-native/issues/2282 is done.
The cleaner-stuff relates to that other thread where I mentioned that maybe we should give up on manually cleaning the cache because it only works if MapLibre has been initialized on the main thread. TBH I think maybe it is not that complex to implement in MapLibre proper. As in the OfflineManager, there is already an option to limit the cache size, I am sure that MapLibre already internally remembers which tile has been downloaded when because it would make most sense to first evict the oldest downloaded tiles from the cache.
The ReentrantLock thing will be very hard to find, as not in a single line in the stack trace, StreetComplete is mentioned.
This and the coming week, I will not work on this PR.
Stack trace number three might also be related to Koin. It looks as if the system was unable to initialize the worker at all.
I reduced the time until the regions get removed, lets see how the db has changed tomorow.
Did not work. SC was not closed and there were no crashes, but to offline region cleanup happened.
It worked correctly when I added mapTilesDownloader.deleteRegionsOlderThan
to startup code. Maybe we could just call it every time the map is initialized? It's not doing any heavy work, so should not noticeably slow down anything.
pre-6 has been released - https://github.com/maplibre/maplibre-native/releases/tag/android-v11.0.0-pre6
It worked correctly when I added mapTilesDownloader.deleteRegionsOlderThan to startup code. Maybe we could just call it every time the map is initialized? It's not doing any heavy work, so should not noticeably slow down anything.
I guess that would be the workaround. I.e. not have the OfflineManager in the Cleaner at all, but do it on initializing the map. This will put some IO work at startup though, i.e. at the time at which we do a lot of IO anyway.
This will put some IO work at startup though, i.e. at the time at which we do a lot of IO anyway.
It's not really important to be done immediately on start, we could e.g. delay it by 30 seconds.
For simple comparison with master, and for discussions.
to do
CustomGeometrySource
(draft started by @Helium314)~ blocked by at least maplibre-native#2262 and not strictly necessaryto do SCEE
upstream blockers
old observations below
Performance regarding icons (symbol layers, mostly about quest pins):
Other things:
This request was cancelled (https://api.jawg.io/glyphs/Roboto%20Regular%2cNoto%20Regular/0-255.pbf). This is expected for tiles that were being prefetched but are no longer needed for the map to render.
. It's not horrible, but downloading the same thing on every start seems like a waste of bandwidth and resources.