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

Make the MapControl disposable and not the Map #2372

Open
pauldendulk opened this issue Dec 29, 2023 · 0 comments
Open

Make the MapControl disposable and not the Map #2372

pauldendulk opened this issue Dec 29, 2023 · 0 comments
Milestone

Comments

@pauldendulk
Copy link
Member

pauldendulk commented Dec 29, 2023

Note: This is an idea which might be hard to realized, perhaps impossible. Still I think it is good way to think about this problem because it is a clear objective. The solution that comes out of this may be different.

The problem
We need to deal with a lot of IDisposable classes in our code base. There are a lot of issues cause by this. We need to think about it in most of our PRs. If I search for 'SuppressMessage("IDisposableAnalyzers' I get 100 hits. 😬

The proposed solution
Rewrite our code so that the user only needs to dispose the MapControl. Of course many of it's children need to be disposed, but that that is not the users problem. The Map and its children (Layers) should not need dispose.

Is this feasible? What kind of things do we need to dispose right now?
My idea right now is that we have a couple of categories that will always need dispose. Those are:

  • SkiaSharp object. This is part of the rendering. The Renderer is a field in the MapControl. Those need to be cached and the renderer should be responsible to clear and dispose the cache.
  • Timers. Those are mostly related to fetching. This could be resolved with a centralized fetcher in the MapControl.
  • HttpClient and database access. Those are part of the providers. Perhaps we need to register the providers to a registry that is owned by the MapControl (I don't have a clear picture of how that should work. Perhaps a layers only specifies which kind of Provider is used, and the fetcher creates and disposes it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant