Skip to content

Commit

Permalink
Fix some render tasks being skipped (#1306)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiryldz authored Apr 27, 2022
1 parent 592e1e0 commit 41ab43c
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 35 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Mapbox welcomes participation and contributions from everyone.
* Optimize how plugins handle settings changes. Call `applySettings` only when settings value changes. ([#1189](https://github.com/mapbox/mapbox-maps-android/pull/1189))
* Add new Exception type `MapboxMapMemoryLeakException` which will be thrown when there is a leak for nativeMap. ([1193](https://github.com/mapbox/mapbox-maps-android/pull/1193))

# 10.4.3 April 27, 2022

### Bug fixes 🐞
* Fix render tasks being skipped when creating the map that could lead to missing tiles. ([#1304](https://github.com/mapbox/mapbox-maps-android/pull/1304))

# 10.4.2 April 13, 2022

### Bug fixes 🐞
Expand Down
2 changes: 1 addition & 1 deletion extension-localization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.extension:maps-localization:10.4.2'
implementation 'com.mapbox.extension:maps-localization:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion extension-style/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.extension:maps-style:10.4.2'
implementation 'com.mapbox.extension:maps-style:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-animation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-animation:10.4.2'
implementation 'com.mapbox.plugin:maps-animation:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-annotation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-annotation:10.4.2'
implementation 'com.mapbox.plugin:maps-annotation:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-attribution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-attribution:10.4.2'
implementation 'com.mapbox.plugin:maps-attribution:10.4.3'
}
```

Expand Down
4 changes: 2 additions & 2 deletions plugin-compass/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-compass:10.4.2'
implementation 'com.mapbox.plugin:maps-compass:10.4.3'
// Mapbox Maps Compass Plugin depends on the Mapbox Maps Animation Plugin
implementation 'com.mapbox.plugin:maps-animation:10.4.2'
implementation 'com.mapbox.plugin:maps-animation:10.4.3'
}
```

Expand Down
4 changes: 2 additions & 2 deletions plugin-gestures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-gestures:10.4.2'
implementation 'com.mapbox.plugin:maps-gestures:10.4.3'
// Mapbox Maps Gestures Plugin depends on the Mapbox Maps Animation Plugin
implementation 'com.mapbox.plugin:maps-animation:10.4.2'
implementation 'com.mapbox.plugin:maps-animation:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-lifecycle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-lifecycle:10.4.2'
implementation 'com.mapbox.plugin:maps-lifecycle:10.4.3'
// Make sure the version of appcompat is 1.3.0+
implementation 'androidx.appcompat:appcompat:1.3.0'
}
Expand Down
2 changes: 1 addition & 1 deletion plugin-locationcomponent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ allprojects {
}
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-locationcomponent:10.4.2'
implementation 'com.mapbox.plugin:maps-locationcomponent:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-logo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-logo:10.4.2'
implementation 'com.mapbox.plugin:maps-logo:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-overlay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-overlay:10.4.2'
implementation 'com.mapbox.plugin:maps-overlay:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-scalebar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ allprojects {
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-scalebar:10.4.2'
implementation 'com.mapbox.plugin:maps-scalebar:10.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion plugin-viewport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ allprojects {
}
// In the app build.gradle file
dependencies {
implementation 'com.mapbox.plugin:maps-viewport:10.4.2'
implementation 'com.mapbox.plugin:maps-viewport:10.4.3'
}
```

Expand Down
32 changes: 12 additions & 20 deletions sdk/src/main/java/com/mapbox/maps/renderer/MapboxRenderThread.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.mapbox.common.Logger
import com.mapbox.maps.renderer.egl.EGLCore
import com.mapbox.maps.renderer.gl.TextureRenderer
import com.mapbox.maps.renderer.widget.Widget
import java.util.LinkedList
import java.util.concurrent.ConcurrentLinkedQueue
import java.util.concurrent.locks.ReentrantLock
import javax.microedition.khronos.egl.EGL10
Expand Down Expand Up @@ -147,12 +146,15 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
// finally we can create native renderer if needed or just report OK
if (eglContextCreated) {
if (!renderCreated) {
// we set `renderCreated` as `true` before creating native render as core could potentially
// schedule task in the same callchain and we need to make sure that `renderThreadPrepared` is already `true`
// so that we do not drop this task
renderCreated = true
mapboxRenderer.createRenderer()
mapboxRenderer.onSurfaceChanged(
width = width,
height = height
)
renderCreated = true
}
return true
}
Expand Down Expand Up @@ -419,9 +421,11 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
if (renderThreadPrepared && !paused) {
draw()
}
// we drain queue despite buffers swapped or not
drainQueue(nonRenderEventQueue)
awaitingNextVsync = false
// It's critical to drain queue after setting `awaitingNextVsync` to false as some tasks may recursively schedule other tasks when executed.
// With `awaitingNextVsync = false` we will always schedule recursive tasks for later execution
// via `renderHandlerThread.postDelayed` instead of updating queue concurrently that is being drained (which may lead to deadlock in core).
drainQueue(nonRenderEventQueue)
}

@AnyThread
Expand Down Expand Up @@ -508,22 +512,10 @@ internal class MapboxRenderThread : Choreographer.FrameCallback {
}

private fun drainQueue(originalQueue: ConcurrentLinkedQueue<RenderEvent>) {
if (originalQueue.isNotEmpty()) {
// we iterate over immutable copy in order to avoid executing recursive tasks
val localQueueCopy = LinkedList(originalQueue)
// clear original queue before executing
originalQueue.clear()
localQueueCopy.forEach {
it.runnable?.run()
}
// recursive tasks (if any) were added to the original queue - post draining them in new callchain
if (originalQueue.isNotEmpty()) {
renderHandlerThread.post {
if (renderThreadPrepared) {
drainQueue(originalQueue)
}
}
}
var event = originalQueue.poll()
while (event != null) {
event.runnable?.run()
event = originalQueue.poll()
}
}

Expand Down

0 comments on commit 41ab43c

Please sign in to comment.