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

Android 10.3.2 pre #2423

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/mbgl/util/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum class EventSeverity : uint8_t {
Info,
Warning,
Error,
SeverityCount
};

enum class Event : uint8_t {
Expand Down
2 changes: 1 addition & 1 deletion include/mbgl/util/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Log {
Log();
~Log();

static void useLogThread(bool enable);
static void useLogThread(bool enable, optional<EventSeverity> = {});

template <typename ...Args>
static void Debug(Event event, Args&& ...args) {
Expand Down
4 changes: 4 additions & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ MapLibre welcomes participation and contributions from everyone. Please read [`C

### ✨ Features and improvements

# 10.3.2-pre0

A special release for a particular user experiencing rare crashes in the field only. See [#2423](https://github.com/maplibre/maplibre-native/pull/2423) for more information

### 🐞 Bug fixes

## 10.3.1
Expand Down
2 changes: 1 addition & 1 deletion platform/android/MapboxGLAndroidSDK/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=10.3.1
VERSION_NAME=10.3.2-pre0

# Only build native dependencies for the current ABI
# See https://code.google.com/p/android/issues/detail?id=221098#c20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,20 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
</activity>
<!-- Benchmark -->
<activity
android:name=".activity.benchmark.BenchmarkActivity"
android:description="@string/description_world_tour_benchmark"
android:exported="true"
android:label="@string/activity_benchmark_world_tour"
>
<meta-data
android:name="@string/category"
android:value="@string/category_benchmark" />
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.FeatureOverviewActivity" />
</activity>
<!-- For Instrumentation tests -->
<activity
android:name=".activity.style.RuntimeStyleTimingTestActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
package com.mapbox.mapboxsdk.testapp.activity.benchmark

import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Handler
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.testapp.R
import java.util.*

class FpsStore {
private val fpsValues = ArrayList<Double>(100000)

fun add(fps: Double) {
fpsValues.add(fps)
}

fun reset() {
fpsValues.clear()
}

fun low1p(): Double {
fpsValues.sort()
return fpsValues.slice(0..(fpsValues.size / 100)).average()
}

fun average(): Double {
return fpsValues.average()
}
}

data class Result(val average: Double, val low1p: Double)

data class Results(
var map: MutableMap<String, List<Result>> = mutableMapOf<String, List<Result>>().withDefault { emptyList() })
{

fun addResult(styleName: String, fpsStore: FpsStore) {
val newResults = map.getValue(styleName).plus(Result(fpsStore.average(), fpsStore.low1p()))
map[styleName] = newResults
}
}

/**
* Benchmark using a [android.view.TextureView]
*/
class BenchmarkActivity : AppCompatActivity() {
private lateinit var mapView: MapView
private lateinit var maplibreMap: MapboxMap
private var handler: Handler? = null
private var delayed: Runnable? = null
private var fpsStore = FpsStore()
private var results = Results()
private var runsLeft = 5

// the styles used for the benchmark
// can be overridden adding with developer-config.xml
// ```xml
// <array name="benchmark_style_names">
// <item>Americana</item>
// </array>
// <array name="benchmark_style_urls">
// <item>https://zelonewolf.github.io/openstreetmap-americana/style.json</item>
// </array>
// ```
private var styles = listOf(Pair("Demotiles", "https://demotiles.maplibre.org/style.json"))

@SuppressLint("DiscouragedApi")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_benchmark)
handler = Handler(mainLooper)
setupToolbar()
setupMapView(savedInstanceState)

val styleNames = resources.getStringArray(applicationContext.resources.getIdentifier(
"benchmark_style_names",
"array",
applicationContext.packageName))
val styleURLs = resources.getStringArray(applicationContext.resources.getIdentifier(
"benchmark_style_urls",
"array",
applicationContext.packageName))
if (styleNames.isNotEmpty() && styleNames.size == styleURLs.size) {
styles = styleNames.zip(styleURLs)
}
}

private fun setupToolbar() {
val actionBar = supportActionBar
if (actionBar != null) {
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
supportActionBar!!.setHomeButtonEnabled(true)
}
}

private fun setupMapView(savedInstanceState: Bundle?) {
mapView = findViewById<View>(R.id.mapView) as MapView
mapView.getMapAsync { maplibreMap: MapboxMap ->
[email protected] = maplibreMap
maplibreMap.setStyle(styles[0].second)
setFpsView(maplibreMap)

// Start an animation on the map as well
flyTo(maplibreMap, 0, 0,14.0)
}
}

private fun flyTo(maplibreMap: MapboxMap, place: Int, style: Int, zoom: Double) {
maplibreMap.animateCamera(
CameraUpdateFactory.newLatLngZoom(PLACES[place], zoom),
10000,
object : MapboxMap.CancelableCallback {
override fun onCancel() {
delayed = Runnable {
delayed = null
flyTo(maplibreMap, place, style, zoom)
}
delayed?.let {
handler!!.postDelayed(it, 2000)
}
}

override fun onFinish() {
if (place == PLACES.size - 1) { // done with tour
results.addResult(styles[style].first, fpsStore)
fpsStore.reset()

println("FPS results $results")

if (style < styles.size - 1) { // continue with next style
maplibreMap.setStyle(styles[style + 1].second)
flyTo(maplibreMap, 0, style + 1, zoom)
} else if (runsLeft > 0) { // start over
--runsLeft
maplibreMap.setStyle(styles[0].second)
flyTo(maplibreMap, 0, 0, zoom)
} else {
finish()
}
return
}

// continue with next place
flyTo(maplibreMap, place + 1, style, zoom)
}
}
)
}

private fun setFpsView(maplibreMap: MapboxMap) {
maplibreMap.setOnFpsChangedListener { fps: Double ->
fpsStore.add(fps)
}
}

override fun onStart() {
super.onStart()
mapView.onStart()
}

override fun onResume() {
super.onResume()
mapView.onResume()
}

override fun onPause() {
super.onPause()
mapView.onPause()
}

override fun onStop() {
super.onStop()
mapView.onStop()
if (handler != null && delayed != null) {
handler!!.removeCallbacks(delayed!!)
}
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
mapView.onSaveInstanceState(outState)
}

override fun onDestroy() {
super.onDestroy()
mapView.onDestroy()
}

override fun onLowMemory() {
super.onLowMemory()
mapView.onLowMemory()
}

companion object {
private val PLACES = arrayOf(
LatLng(37.7749, -122.4194), // SF
LatLng(38.9072, -77.0369), // DC
LatLng(52.3702, 4.8952), // AMS
LatLng(60.1699, 24.9384), // HEL
LatLng(-13.1639, -74.2236), // AYA
LatLng(52.5200, 13.4050), // BER
LatLng(12.9716, 77.5946), // BAN
LatLng(31.2304, 121.4737) // SHA
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.benchmark.BenchmarkActivity">

<com.mapbox.mapboxsdk.maps.MapView
android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:maplibre_renderTextureMode="true"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
app:maplibre_cameraTargetLat="38.87031"
app:maplibre_cameraTargetLng="-77.00897"
app:maplibre_cameraZoom="10"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:id="@id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
app:maplibre_cameraTargetLat="45.1855569"
app:maplibre_cameraTargetLng="5.7215506"
app:maplibre_cameraZoom="11"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
app:maplibre_cameraTargetLat="52.0907"
app:maplibre_cameraTargetLng="5.1214"
app:maplibre_cameraZoom="16"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
<string name="fps30">fps30</string>
<string name="fps60">fps60</string>
<string name="this_is_an_empty_fragment">This is an empty Fragment</string>
<string name="category_benchmark">Benchmark</string>
<string name="activity_benchmark_world_tour">World Tour Benchmark</string>
<string name="description_world_tour_benchmark">Writes out avg. fps and 1% fps after world tour with .flyTo()</string>
</resources>
60 changes: 60 additions & 0 deletions src/mbgl/layout/symbol_instance.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <mbgl/layout/symbol_instance.hpp>
#include <mbgl/style/layers/symbol_layer_properties.hpp>
#include <mbgl/util/logging.hpp>

#include <utility>

namespace mbgl {
Expand Down Expand Up @@ -199,4 +201,62 @@ optional<size_t> SymbolInstance::getDefaultHorizontalPlacedTextIndex() const {
if (placedLeftTextIndex) return placedLeftTextIndex;
return nullopt;
}

bool SymbolInstance::check(std::size_t v, int n, std::string_view source) const {
if (!isFailed && v != checkVal) {
isFailed = true;
Log::Error(Event::Crash, "SymbolInstance corrupted at " + util::toString(n) + " with value " + util::toString(v) + " from '" + std::string(source) + "'");
}
return !isFailed;
}

bool SymbolInstance::checkKey() const {
if (!isFailed && key.size() > 1000) { // largest observed value=62
isFailed = true;
Log::Error(Event::Crash, "SymbolInstance key corrupted with size=" + util::toString(key.size()));
}
return !isFailed;
}

bool SymbolInstance::checkIndex(const optional<std::size_t>& index, std::size_t size, std::string_view source) const {
if (index.has_value() && *index >= size) {
isFailed = true;
Log::Error(Event::Crash, "SymbolInstance index corrupted with value=" + util::toString(*index) + " size=" + util::toString(size) + " from '" + std::string(source) + "'");
}
return !isFailed;
}

// this is just to avoid warnings about the values never being set
void SymbolInstance::forceFail() {
check01 =
check02 =
check03 =
check04 =
check05 =
check06 =
check07 =
check08 =
check09 =
check10 =
check11 =
check12 =
check13 =
check14 =
check15 =
check16 =
check17 =
check18 =
check19 =
check20 =
check21 =
check22 =
check23 =
check24 =
check25 =
check26 =
check27 =
check28 =
check29 = 0;
}

} // namespace mbgl
Loading
Loading