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

When touching and holding a long press, mapControl becomes blank #2396

Open
zimuyanghua opened this issue Jan 8, 2024 · 6 comments
Open
Labels
help-wanted Could be implemented by outside contributors possible-bug

Comments

@zimuyanghua
Copy link

Mapsui Version
Mapsui 4.1

Mapsui Platform
Avalonia

Device
Linux

Describe the bug
I load a map in mbtiles format, and when I touch and hold the screen, the map becomes blank. However, I don't encounter this issue when I long-press with a mouse. It seems to trigger the system's long-press for right-click gesture.

I haven't added any additional code, just loaded the map, and no exceptions were thrown.

QQ202418-14468.mp4

I'm not sure if this is a bug or not.

@zimuyanghua
Copy link
Author

I added the log
Mapsui.Logging.Logger.LogDelegate += (level, message, ex) =>
{
Console.WriteLine(message); // <-- Put a break point here, most UI platforms do not show the console logging.
// todo: Forward to your own logger
};
output:

Unexpected error in skia renderer

@zimuyanghua
Copy link
Author

more detail about the error:
e4e50dc46b6fcddb407ffb497a3be280

@pauldendulk
Copy link
Member

Given the number of things on my plate this is not something I will try to reproduce. I don't have a touch screen and don't work default on Linux.

The bug could be related to extreme values (near zero or maximum double) in the unitsPerPixel, or something weird in the resolutions. It is probably a real bug in Mapsui or BruTile. It could also be a bug in Avalonia.

What you could do it try to reproduce it with the Avalonia sample that is part of this git repository.

git clone git@github.com:Mapsui/Mapsui.git

And run the Avalonia sample.

This is the method in BruTile that is involved.

public static int GetNearestLevel(IDictionary<int, Resolution> resolutions, double unitsPerPixel)
{
    if (resolutions.Count == 0)
    {
        throw new ArgumentException("No tile resolutions");
    }

    var orderedResolutions = resolutions.OrderByDescending(r => r.Value.UnitsPerPixel).ToList();

    //smaller than smallest
    if (orderedResolutions.Last().Value.UnitsPerPixel > unitsPerPixel) return orderedResolutions.Last().Key;

    //bigger than biggest
    if (orderedResolutions.First().Value.UnitsPerPixel < unitsPerPixel) return orderedResolutions.First().Key;

    var result = -1;
    var resultDistance = double.MaxValue;
    foreach (var current in orderedResolutions)
    {
        var distance = Math.Abs(current.Value.UnitsPerPixel - unitsPerPixel);
        if (distance < resultDistance)
        {
            result = current.Key;
            resultDistance = distance;
        }
    }
    if (result < 0) throw new Exception("Unexpected error when calculating nearest level");
    return result;
}

@pauldendulk
Copy link
Member

oh and I forgot. Thanks for the bug report! The movie really helps.

@zimuyanghua
Copy link
Author

I tried the Avalonia demo and this issue also occurs. Since the test environment can only be offline, I only tested the mbtiles format. I'll try again with a map in a different offline format

@pauldendulk pauldendulk added the help-wanted Could be implemented by outside contributors label Jan 9, 2024
@pauldendulk
Copy link
Member

I tried the Avalonia demo and this issue also occurs.

But that means you could retrieve can see what is happening in the debugger when result is smaller than zero. What are argument values for the resolutions and the unitsPerPixel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Could be implemented by outside contributors possible-bug
Projects
None yet
Development

No branches or pull requests

2 participants