Skip to content

Conversation

@zach-snell
Copy link

@zach-snell zach-snell commented Mar 4, 2025

Resolves issues around date line and rotation with infinite scrolling longitudinal map. May still need clean up / optimization.

…d dateline and rotation with infinite scrolling longitudinal map. May still need clean up / optimization.
Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zach-snell, thanks for opening a PR!

I would be grateful if you could give a little more info as to what this PR fixes.

As I'm testing it, I'm comparing it to the master branch, and I can't see any difference in behaviour. Could you record some videos to show what failed before, and the fixed behaviour with your PR? I'm just struggling to understand why these changes are necessary, particularly with the oscillation fixes, as I've not experienced any oscillations.

As far as I understand, #2019 is completely unrelated to unbounded horizontal scrolling, and instead about issues with the TileLayer not being able to be changed properly. Could you explain how your PR fixes and relates to #2019?

Comment on lines 96 to 107
if (i == 0) {
result = addedWidth;
bestX = x;
bestError = error;
continue;
}
if ((bestX + ox - halfScreenWidth).abs() >
(x + ox - halfScreenWidth).abs()) {

// Only switch worlds if there's a significant improvement
// This prevents oscillation near the boundary
if (error < bestError - hysteresisThreshold) {
result = addedWidth;
bestX = x;
bestError = error;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be collapsed into a single decision?

I'm also not aware of any situation where oscillation at the boundary is an issue? Did you reproduce this? As far as I understand, this is very different to #2019, but I'm probably missing something.

// Only switch worlds if there's a significant improvement
// This prevents oscillation near the boundary
if (i == 0 || error < bestError - hysteresisThreshold) {
	result = addedWidth;
	bestError = error;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to give this a test - I had also noticed that the second assignment of bestX / bestError seemed unused. I knew I would need to review that anyways.

Further, I remember this was related but I was iterating so many times I will confirm if reverting has impact and if so if we can simplify the logic.

@zach-snell
Copy link
Author

@JaffaKetchup

You know, I think you're right. I was half asleep I guess and didn't relate the valid issue.

I will record a video showing the issue I was resolving later this morning.

--

The issue was with the way the camera / tiles would flicker or jump from east to west as you move back and forth near the date line.

@zach-snell zach-snell changed the title Initial working fix - Resolves #2019 and related issues around date line Initial working fix - Resolves date line related issues. Mar 4, 2025
@zach-snell
Copy link
Author

zach-snell commented Mar 4, 2025

Alright - adding some visuals here.
I was way down the rabbit hole through flutter_map plugins related.

I suppose the issues with flickering were at that layer but as I determined I was unable to resolve them there, there had to be a big in the core. That is what brought me to resolving this tiny yet incredibly annoying edge-case where you all luckily had a visual example already built that showed it well.

This shows as the following in main branch

Resolved, no issue with lat/long and screen smoothing

For more context, downstream in flutter_vector_map_tiles
This is after I upgraded a bunch of code to even be able to work with flutter_map 8.1.0.

I do also want to make sure none of my changes are bleeding through - there was a point where I couldn't drag the screen across the 180/-180 area until I adjusted the drag logic but building main this morning it was magically working.

We all know how these things go where magical issues show up and disappear so I will do a bit more testing tonight / after work.

@zach-snell zach-snell force-pushed the bugfix/#2019-dateline-smoothing branch from 6b32005 to 12ea190 Compare March 4, 2025 21:41
@zach-snell
Copy link
Author

zach-snell commented Mar 4, 2025

Turns out I was able to reproduce the dateline issue when I removed the drag logic. I don't know why I couldn't reproduce before. Flutter messing with me - I even ran flutter clean, flutter pub clean, deleted all build artifacts etc but could not reproduce earlier.

Attaching demonstration of that issue and the resolved version.

Demonstrating issue
I know you can't see my mouse here but the stop is pretty obvious as it locks at 180 when I try to drag across.

Working resolution

Feel free to test on main to see if you see the same thing.
Once I reproduced, I was able to quickly change back and forth and hot-reload to see the issue.

I am going to try and isolate a bit to make sure its not self-introduced/resolved.

@zach-snell
Copy link
Author

Alright! Very much simplified -- turns out there was a chain of self-created issues in there.
I had slowly found the resolution and part of that path introduced unnecessary code which created problems I then resolved.

This should be much easier to review!

@JaffaKetchup JaffaKetchup requested review from a team and JaffaKetchup March 4, 2025 22:55
@JaffaKetchup
Copy link
Member

Sorry, been focused on some other PRs. I'm still not sure what this PR is fixing. As far I can see, I can move across the dateline completely fine in the example app on that page.

@zach-snell
Copy link
Author

zach-snell commented Mar 20, 2025 via email

@JaffaKetchup
Copy link
Member

I can't reproduce anything like is shown in the video at all. Are you using a mouse on a real device?

@JaffaKetchup
Copy link
Member

JaffaKetchup commented Mar 23, 2025

For the time being, I'm going to close this, because I'm still unsure if there's an issue. Whilst I can see something strange in the screen recording, I can't reproduce this. If you're still having the issue, please file a bug report! Thanks for the contributions anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants