When using Optimize, we often need instances of bpmn-js viewers, e.g. to display the model, to extract flow node names or to enable user interactions. Right now we always create a new instance by parsing the xml in the report configuration.
This parsing takes a lot of time. Since the xml does not change for a process definition and version (with some exceptions, e.g. version "ALL" or if someone deletes a process and re-deploys it), we could think about parsing the xml only once and then caching the result.
We need to especially take care of changes to the cached instance (e.g. by registering event listeners or adding heatmaps), so that the cached instance can be re-used. I think Cockpit has a similar caching mechanism, maybe we can
steal it get some inspiration.