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

BitmapRegistry.Unregister() doesn't remove bitmap from lookup array #2386

Open
charlenni opened this issue Jan 4, 2024 · 3 comments
Open
Labels

Comments

@charlenni
Copy link
Member

Mapsui Version
All

Mapsui Platform
All

Device
All

Describe the bug
If you remove a bitmap with BitmapRegistry.Instance.Unregister() it is deleted from array _register but not from _lookup. If you now try to get a bitmap via BitmapRegistry.Instance.TryGetBitmapId(), the bitmap is found in lookup, but isn't longer in _register.

Expected behavior
BitmapId should also deleted in lookup array.

@charlenni
Copy link
Member Author

I found even more problems, which brought me to the conclusion, not to use Unregister(). If we want to use it, we need a counter system, set track, how often a bitmap is used and if it is the last unregister call, remove it.

@pauldendulk
Copy link
Member

Perhaps a first step is to remove Unregister(). What was the reason you used it? (to get an impression of the use case).

A general thing we need to work on is to get an overview of all caching we are using in Mapsui. Over the years we added many caches in different places. It should at least be possible to disable caching. This should affect performance and not functionality. In some cases this is not possible. This means it is not a cache but in in-memory datastore, and we need to think about it in a different way.

@charlenni
Copy link
Member Author

I used it when working on the markers. You could create pins with whatever color you want. This is done with string replacement of the original color and then the SVG is registered. But if you replace this bitmap entry with a new one (change color), a new bitmap is added. So I thought, it would be a good idea to remove the old one. But I thought not about what happen, if two pins have the same color and only one get a new color.

So, yes, I have to think about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants