Skip to content

Map.OlMap memory leaks and event re-attaching. #406

@Drahness

Description

@Drahness

Describe the bug

Where a instance is given to OlMap vue component, it attaches handles for all events even if when are not used by the consumer, it causes overhead emitting events with no purpose, in the worst case, if an instance is used in more than once can cause multiple events to fire with undefined behaviour.

Affected version(s)

+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

To Reproduce
Steps to reproduce the behaviour:

  • Mount a Map.OlMap component a condition and with a given 'instance' not controlled by vue3-openlayers.
  • Change the condition to force a remount of the Vue component, calling the "on" method in all event types of OpenLayers Map.
  • Repeat.

Expected behaviour

Handler functions added from Map are properly disconnected when Map.OlMap Vue component is dismounted, if an event is not used, do not call to the on method in the map instance. This logic can be applied to vue3-openlayers controlled "Map" instances.

Screenshots
Current code:

Image

Crappy solution:

Image

Platform

  • All platforms

Additional context

I saw in "src/composables/useOpenLayersEvents.ts" has a good function to attach that logic, I posted this issue because I cannot run locally the project and I doesn't found a guide to do so.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions