mapbox / mapbox/mapbox-maps-android

Black screen when switching from smartphone app to Android Auto

Open
#2,468 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
Dominant language
Kotlin
Stars
578
Forks
161
PR merge metrics
No merged PRs in 30d

Description

## Environment

- Android OS version: 14
- Devices affected: Samsung
- Tested Device: Samsung Galaxy S23 FE
- Maps SDK Version: 10.13.0 & 11.6.0

## Observed behavior and steps to reproduce

In our app we always close (finish) the smartphone app, once the Android Auto app has been launched by the user - to reduce load and keep the focus of the user on the head unit.

Exclusively on Samsung devices running Android 14 we've noticed, that the map surface in the head unit always turns black after a while, if the app was first launched on the smartphone.

At first the map screen is fully rendered, but after returning from another screen (i.e. Search) the map surface stays black. Only thing the user can now do in that situation is to close the app completely and directly start it manually via the head unit.

The following error log is constantly repeating while the screen is black.

```
[maps-android\Mbgl-RenderThread]: renderThreadPrepared=false but Android surface is valid, trying to recreate EGL...
[maps-android\Mbgl-RenderThread]: Setting up render thread, flags: creatingSurface=true, nativeRenderCreated=true, eglContextMadeCurrent=false, eglContextCreated=true, paused=false
[maps-android\Mbgl-EglCore]: eglCreateWindowSurface: EGL error: 0x300b
[maps-android\Mbgl-EglCore]: EGL error 12299 occurred for eglCreateWindowSurface!
[maps-android\Mbgl-RenderThread]: Could not create EGL surface although Android surface was valid, retrying in 50 ms...
[maps-android\Mbgl-RenderThread]: Setting up render thread failed, check logs above.
[maps-android\Mbgl-RenderThread]: renderThreadPrepared=false but Android surface is valid, trying to recreate EGL...
[maps-android\Mbgl-RenderThread]: Setting up render thread, flags: creatingSurface=true, nativeRenderCreated=true, eglContextMadeCurrent=false, eglContextCreated=true, paused=false
```

I was able to easily reproduce the behavior in your Android Auto example app, by adding some slight modifications.

1. Added a MapView to the Activity
2. When the CarSession is created the Activity is being finished (quick and dirty approach)

```
class MainActivity : AppCompatActivity() {
companion object {
var instance: MainActivity? = null
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

instance = this
}
}

```

```
class MapSession : Session() {
private val carMapShowcase = CarMapShowcase()
override fun onCreateScreen(intent: Intent): Screen {
MainActivity.instance?.finish()
```

## Expected behavior

The map screen should not turn black after returning to the map screen.

## Additional links and references

https://github.com/user-attachments/assets/2bff183e-0dcf-421d-a73b-450281e19c38

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Android Auto example app and the MapView, MainActivity, and MapSession code shown in the report. Reproduce the transition on a Samsung Galaxy S23 FE running Android 14, then inspect the repeated EGL and render-thread errors while returning from Search to the map. Done means the map remains rendered after the smartphone Activity is finished.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.