maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.06k stars 310 forks source link

PIXEL: ioctl err: 1 on non-emulated Pixel hardware #2121

Open chjaeggi opened 8 months ago

chjaeggi commented 8 months ago

Describe the bug I am referring to the discussion in here: https://github.com/maplibre/maplibre-native/discussions/1998 There seems to be a bug especially when dragging around in a map (or when re-drawing it thereby). It gets worse the more frequent the redrawing happens (for instance with an animated location indicator), the phone gets really hot (because of those I/O errors)

To Reproduce I included a minimal sample in the discussion afformentioned. Here again for summary:


class MainActivity : ComponentActivity() {

    private fun setUpMapLibre(okHttpClient: OkHttpClient) {
        Mapbox.getInstance(this, null, WellKnownTileServer.MapLibre)
        HttpRequestUtil.setOkHttpClient(okHttpClient)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        val okHttpClient = OkHttpClient.Builder().build()
        setUpMapLibre(okHttpClient)

        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme {
                Surface(
                    modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background
                ) {
                    val context = LocalContext.current
                    val mapView = MapView(context).apply {
                        getMapAsync { map ->
                            map.apply {
                                setStyle("https://raw.githubusercontent.com/maplibre/demotiles/gh-pages/styles/osm-bright-gl-style/style.json") {
                                    LocationComponentActivationOptions.builder(context, it).build()
                                }
                            }
                        }
                    }
                    AndroidView(factory = { mapView })
                }
            }
        }
    }
}

Expected behavior No PIXEL: ioctl err: 1 output

Screenshots

Platform information (please complete the following information):

Additional context See discussion thread

louwers commented 8 months ago

I cannot reproduce the problem, but this style is also known to be malfunctioning. Try with another tile source please.

chjaeggi commented 8 months ago

Did you use a real pixel device? Not an emulated one? Me and my colleagues can reproduce it independent of a particular style on these phones.

There are other styles causing this issue even more like this: https://demotiles.maplibre.org/styles/osm-bright-gl-terrain/style.json

and not so frequent but still explorable especially when pinch to zoom closely: https://demotiles.maplibre.org/style.json

please note those are styles provided in your demo application.

How should we proceed, please advise,

Cheers C

louwers commented 8 months ago

I tested on a Samsung S10 and a Google Pixel 7.

What version of OkHttp are you using?

Does the error occur if you don't set the HTTP client?

chjaeggi commented 8 months ago

The one mentioned in the discussion, let's see:

implementation("com.squareup.okhttp3:okhttp:4.11.0")

Without the client I am not able to fetch the style, am I?

louwers commented 8 months ago

@chjaeggi It is not needed, it will fall back to the default ok http client (it is a dependency).

Edit: The 10.2.0 release used OkHttp 4.10.0, so it should be compatible. But you might want to try removing it.

chjaeggi commented 8 months ago

I removed everything related to OKHttp, it really seems an issue with your code accessing disk (as the device is getting hot after a time, not sure about that as I/O could relate to network communication)

louwers commented 8 months ago

Can you provide more output?

Does it happen on other phones too?

What Android version are you using?

We do benchmarking and Android UI tests on Pixel devices and we have not encountered this issue.

chjaeggi commented 8 months ago

At the moment all I have is this:

2024-02-20 16:45:20.705 15143-15375 recomposesample         ch.exmple.mapslibrecomposesample     E  PIXEL: ioctl err: 1
2024-02-20 16:45:20.715 15143-15375 recomposesample         ch.exmple.mapslibrecomposesample     E  PIXEL: ioctl err: 1
2024-02-20 16:45:20.732 15143-15375 recomposesample         ch.exmple.mapslibrecomposesample     E  PIXEL: ioctl err: 1
2024-02-20 16:45:20.749 15143-15375 recomposesample         ch.exmple.mapslibrecomposesample     E  PIXEL: ioctl err: 1
2024-02-20 16:45:20.764 15143-15375 recomposesample         ch.exmple.mapslibrecomposesample     E  PIXEL: ioctl err: 1
2024-02-20 16:45:20.784 15143-15375 recomposesample         ch.exmple.mapslibrecomposesample     E  PIXEL: ioctl err: 1
2024-02-20 16:45:20.799 15143-15375 recomposesample         ch.exmple.mapslibrecomposesample     E  PIXEL: ioctl err: 1

... errors counting heavily up

There is not more output besides that line unfortunately.

Other phones yes: each pixel we tested so far (Pixel 8 Pro, Pixel Foldable, Pixel 5 and Pixel 4) Version Android 13 and 14.

louwers commented 8 months ago

One last thing you could try is to use an AppCompatActivity instead of a ComponentActivity, since that is what is used for all our testing.

chjaeggi commented 8 months ago

hey there thanks for the support! Unfortunately no success either with an AppCompatActivity and theme <style name="Theme.MapsLibreComposeSample" parent="Theme.AppCompat.NoActionBar" />.

Same error still.

It really is strange that you cannot observe these events on none of your pixel phones

chjaeggi commented 8 months ago

I assume while looking at the code those errors can only originate from the: MapboxGLSurfaceView class which does the heavy lifting and also the error occurs when wandering around the map

chjaeggi commented 7 months ago

any updates?

louwers commented 7 months ago

@chjaeggi Can you try this? I just built it myself and ran it on a clean Pixel 8 Pro (no error). https://drive.google.com/file/d/1FVM4ypLjiRaVxE4jUJuwJRhIj6v_-MKx/view?usp=sharing

If it works there is something wrong with your build setup. If it doesn't work there is probably something wrong with your devices...

louwers commented 7 months ago

animated location indicator

This might be what is making the phone hot. I'll merge this today and release a new pre-release, maybe you could see if that fixes it. https://github.com/maplibre/maplibre-native/pull/2182

chjaeggi commented 7 months ago

What release number would that be? Is it merged already? Thanks for the help

louwers commented 7 months ago

Thhat is a build from main, so the upcoming 11.0.0 release.

chjaeggi commented 7 months ago

sorry for the hassle i generate. any update when this will be released? I have a hard time to debug with all thoses errors and I would love to test the new release. Is there a way I can locally build one myself?

louwers commented 7 months ago

@chjaeggi No problem. The 11.0.0 release is scheduled for the end of this month.

You can build the library with ./gradlew assemble in platform/android. Make sure to clone the submodules. https://github.com/maplibre/maplibre-native/blob/main/platform/android/DEVELOPING.md#getting-the-source