Repository navigation
Desktop-specific initialization makes MapLibre Compose integration less multiplatform #876
Replies: 1 comment 1 reply
|
First, please see the AI policy. AI-written communication requires disclosure. To answer your question: On mobile, each app gets its own dedicated cache directory, so we don't need input from the host. On desktop, unless you're in a sandbox (flatpak or similar) there's no "default" location to put the cache, unless we let different apps share a default with ~/.cache/MapLibre or similar. Initialization will likely always require some platform specific hook. On desktop, it's this hook to get the graphics context and cache directory. On web (next release), similarly getting Skiko's DirectContext. Ideally, you place this where you already initialize your application in platform-specific code, like just inside your |
Uh oh!
There was an error while loading. Please reload this page.
What are you trying to achieve?
Hi!
I'm trying to integrate MapLibre Compose into a Compose Multiplatform project while keeping all MapLibre-related dependencies and code inside a single shared KMP module.
For Desktop, however, the current setup requires platform-specific initialization at the application entry point:
This raises a question about the intended multiplatform architecture.
As a library consumer, I would ideally like to:
add the MapLibre Compose dependency only to the shared KMP module;
keep MapLibre UI and integration code in common code;
avoid adding MapLibre-specific initialization to each platform entry point;
avoid exposing platform-specific APIs such as DesktopRuntimeOptions, desktopCachePath, and rememberAwtComposeGpuHost at the application level.
Is this platform-specific initialization fundamentally required by MapLibre Native, or is it mainly a limitation of the current Compose API?
In particular, would it be possible for the library to hide these implementation details behind a common multiplatform abstraction, with platform-specific behavior implemented internally?
For example, from the consumer side I would expect an API closer to:
with the platform-specific runtime/host configuration handled by the library where possible.
I understand that the underlying native renderer may require platform-specific resources or lifecycle integration. My concern is specifically about why this responsibility needs to be exposed to the application rather than being encapsulated by the multiplatform library.
Is the current API an intentional design decision? If so, could you clarify the architectural reason behind it?
Thanks!
Affected Platform(s)
Library Version
0.14.0
What have you tried?
I tried following the recommended Desktop setup using MapLibre.configure() with DesktopRuntimeOptions and wrapping the application with ProvideMapHost(rememberAwtComposeGpuHost(window)).
This works, but it requires MapLibre-specific Desktop code in the platform entry point.
I also tried to find a way to keep the entire MapLibre integration inside the shared KMP module, including the dependency and initialization, but I couldn't find a way to do that without exposing Desktop-specific setup to the application.
I'm wondering whether there is an existing approach I'm missing, or whether this is currently required by the library architecture.
Additional context
No response
All reactions