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

Render on Surface's canvas for Android Auto support #532

Open
ankiimation opened this issue Feb 23, 2023 · 11 comments
Open

Render on Surface's canvas for Android Auto support #532

ankiimation opened this issue Feb 23, 2023 · 11 comments

Comments

@ankiimation
Copy link

I'm using the Carto to display maps on my Android application. However, I'm having trouble figuring out how to render the map on the android-auto Navigation Template that already provides a Surface to render on.

Thanks in advance!

@mtehver
Copy link
Contributor

mtehver commented Feb 24, 2023

I know very little about Android Car APIs, so my answer may be a bit off. But looking at the question at high level, I do not think it is possible without complex workarounds. The issue here is that Carto Mobile SDK needs to configure its rendering surface itself, as there are specific format requirement to depth buffer and stencil buffer in order to provide correct rendering. But NavigationTemplate gives a preconfigured Surface instance that may not be configured with these requirements in mind.

A possible workaround would be to render the map using normal MapView instance (or perhaps TextureMapView instance) and then copy the rendered image to the surface provided by NavigationTemplate callback.

@ankiimation
Copy link
Author

I have tried with TextureView but it cant render without attached to a View

@mtehver
Copy link
Contributor

mtehver commented Feb 28, 2023

Ok, if you need to render map without having a view, you would probably need to make a custom MapView class. On the positive side, the class can be implemented in Java/Kotlin, no changes in native C++ code are necessary (if you look at https://github.com/CartoDB/mobile-sdk/blob/master/android/java/com/carto/ui/MapView.java, you can see that most of code simply acts as a stub to BaseMapView, which is implemented in C++). On the negative side, you need to work classes/APIs like EGLDisplay, EGLContext that are rather low level.

@mtehver
Copy link
Contributor

mtehver commented Feb 28, 2023

Perhaps there is also a way to create transparent/invisible MapView, but I am not sure whether this works.

@phileo
Copy link

phileo commented Sep 16, 2023

Ok, if you need to render map without having a view, you would probably need to make a custom MapView class. On the positive side, the class can be implemented in Java/Kotlin, no changes in native C++ code are necessary (if you look at https://github.com/CartoDB/mobile-sdk/blob/master/android/java/com/carto/ui/MapView.java, you can see that most of code simply acts as a stub to BaseMapView, which is implemented in C++). On the negative side, you need to work classes/APIs like EGLDisplay, EGLContext that are rather low level.

@mtehver how would I hook up my custom Carto MapView class to the SurfaceRenderer.java in the Android auto navigation sample app?

Just a general approach or procedure would be great, thanks.

@safe-bug
Copy link

safe-bug commented Nov 6, 2024

@phileo @ankiimation Have you found a solution for Android Auto? I can copy the rendered image to the Android Auto surface, but the issue is that the MapView is attached to a view, so when the app goes into the background, it stops rendering.

@farfromrefug
Copy link
Contributor

@safe-bug you can use TextureMapView which have been added a while back

@safe-bug
Copy link

safe-bug commented Nov 9, 2024

@farfromrefug I've tried TextureMapView but it must be added to view hierarchy in order to always be rendered. For example if I close the app UI and have a service in the background it doesn't render the TextureMapView.

@farfromrefug
Copy link
Contributor

@safe-bug ok not sure, i dont know much about android auto. Have you search the web on how to do what you want?

@safe-bug
Copy link

safe-bug commented Nov 9, 2024

@farfromrefug Android Auto only provides a surface for drawing. I need to pass this surface to Carto for rendering. Is it possible to achieve this by modifying the TextureMapView code?

@farfromrefug
Copy link
Contributor

@safe-bug seems like it is not easy stadiamaps/ferrostar#7. PRs are welcome but for now seems quite hard

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

No branches or pull requests

5 participants