-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Regression] [Android] [Maps] Map locks up after rendering 50 Polylines #20502
Comments
Hi @mfeingol. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Added a repro link: https://github.com/mfeingol/repros/tree/master/LotsOfPolylinesRepro And now I'm not sure this actually did work in 8.0.3. But it is 100% a regression from Xamarin.Forms, where this same scenario works well. |
@mfeingol Can you create a repo of this working in Xamarin.Forms? That would help track down what changed for why it worked in Forms, but not MAUI. |
Hi @mfeingol. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@drasticactions: sorry to bug, but were you able to make any progress on this issue? It's a pretty critical showstopper for my app, and we're not far away from XF deprecation... Thanks. |
I apologize, I'm not on the MAUI Team. It says "Member" as I'm within So no, I haven't made progress. |
@samhouts: sorry to ping you directly, but is there someone on the team I can work with on this? As mentioned above, this is a pretty critical showstopper for my app and we're not far away from XF deprecation... Thanks. |
Yes, it appears to me if you did:
To the point CPU and/or memory are quickly exhausted if the number N is decently large. |
Anecdotally, I set a bp in the decompiled source for |
You'd need to put a breakpoint in the handler / |
Yeah, I put it after the comment in this if (handler.PlatformView is PolylineOptions polylineOptions)
{
// Will throw an exception when added to the map if Points is empty
if (geoPathMapElement.Count == 0) // <<<--- BP HERE
{
polylineOptions.Points.Add(new LatLng(0, 0));
}
else
{
foreach (var position in geoPathMapElement)
{
polylineOptions.Points.Add(new LatLng(position.Latitude, position.Longitude));
}
}
} |
Hello, I also really need this solution. I had an app made in "Kodular" where I inserted line by line in a "foreach" A[i] to B[i], it was capable of compiling more than a thousand points easily on the Google Maps, Note: instantiating more than a thousand points is very fast, less than 1 second, The function that takes about 1 minute for 1000 points is the Please create a new function similar to the one below: |
A workaround could be, only render the polylines in the visible region, or reduce the number of lines (500 in the sample) from every Polyline. Could use the Douglas-Peucker algorithm for example. |
We shouldn't have to apply a complex workaround like this to address a regression in functionality in .NET MAUI vs Xamarin Forms. |
Hello, jsuarezruiz. Thank you for the tip about the "Douglas-Peucker" algorithm; I wasn't aware of it. I created my own algorithm in a simple way by searching for the nearest point, similar to DBSCAN. Some points in my dataset have a final coordinate equal to the starting coordinate of the next point; however, when there are elements between the points, they usually have a distance of up to 15 meters. I work at an electricity distribution company and I use this to plot our distribution network cables on Google Maps. I limited it to 270 polygon groups, but sometimes it fails if the polygon is too large (with many points). I am not able to plot all our "feeder networks" because some are too large. There are several points where MAUI needs improvement, such as changing the colors of the pins and custom icons. Perhaps the solution is to migrate to another framework until MAUI MAPS is more mature. |
You can change the color of the pins and set custom icons of the map. More information here : Customize Map Pins in .NET MAUI by vladislavantonyuk There other maps available, like Mapsui , although I do not recommend it for beginners because documentation is lacking. Maui.GoogleMaps is a pretty nice nuget package that offers interesting functionality as alternative to Maui.Maps. One advantage of MAUI, similar to Xamarin, is the possibility to bind native Java Libraries. This means you can integrate any native Android Java library into your app. There are countless of native Android libraries, for sure you can find something that does what you need. But most times integrating those libraries is a diffcult task. |
@mfeingol any updates on this from the MAUI team? I think I may be experiencing this when I try and add multiple Pins to the collection. |
sigh thanks. I'll probably have to do the same. MAUI good benefit from a more improved Maps control. I only need Android at the moment, so down that path I will go. |
I created a CustomMap class, added an ObservableCollection to that class, registered for changes to that in the handler, and then did something like this: void AddPolyline(CustomPolyline polyline)
{
Android.Gms.Maps.Model.PolylineOptions options = new();
if (polyline.StrokeColor != null)
options.InvokeColor(polyline.StrokeColor.ToAndroid());
options.Clickable(true);
options.Visible(true);
options.Add(polyline.Select(p => p.ToLatLng()).ToArray());
Android.Gms.Maps.Model.Polyline mapPolyline = this.Map.AddPolyline(options);
// etc
} |
I have a feeling that this might have the same issue on iOS at least. Especially since i'm working with like 600+ polylines at once. I'm still trying to find a way to optimize it |
Description
My app has a scenario in which it renders a number of GPX tracks. When this number is relatively large (50), the process hangs and appears to be stuck in an infinite loop. Nothing visible in the managed debugger, but endless trace output like this:
Steps to Reproduce
Run the repro app. Inside the app, click on the
Lots of Polylines
option at the bottom of the menu.If the page renders a map with some lines, then the test succeeded and there is no bug.
If the app hangs with unhappy GC messages, then the bug has been reproduced.
Change the
count
andsteps
values in theLotsOfPolylinesPage
class to simulate a different number of tracks and number of locations in each track. The app falls over at around 46000 total locations.Link to public reproduction project repository
https://github.com/mfeingol/repros/tree/master/LotsOfPolylinesRepro
Version with bug
8.0.6
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
8.0.3
Affected platforms
Android
Affected platform versions
13
Did you find any workaround?
No workaround.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: