Skip to content

Commit ad139e6

Browse files
committed
Disable parallel map layer loading for now
Signed-off-by: Kyle Corry <[email protected]>
1 parent 2b78c19 commit ad139e6

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

app/src/main/java/com/kylecorry/trail_sense/shared/map_layers/MapLayerBackgroundTask.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ class MapLayerBackgroundTask {
6262
val taskCopy = synchronized(taskLock) {
6363
tasks.toList()
6464
}
65-
val parallel = ParallelCoroutineRunner()
66-
parallel.run(taskCopy.map { { it(bounds, metersPerPixel) } })
65+
for (task in taskCopy) {
66+
task(bounds, metersPerPixel)
67+
}
68+
// TODO: Parallel execution is not working properly - I think it's cancellation related
69+
// val parallel = ParallelCoroutineRunner()
70+
// parallel.run(taskCopy.map { { it(bounds, metersPerPixel) } })
6771
}
6872
) {
6973

app/src/main/java/com/kylecorry/trail_sense/shared/map_layers/MapLayerBackgroundTask2.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.kylecorry.trail_sense.shared.map_layers
22

33
import com.kylecorry.andromeda.core.cache.AppServiceRegistry
44
import com.kylecorry.luna.coroutines.CoroutineQueueRunner
5-
import com.kylecorry.luna.coroutines.ParallelCoroutineRunner
65
import com.kylecorry.sol.math.geometry.Rectangle
76
import com.kylecorry.sol.science.geology.CoordinateBounds
87
import com.kylecorry.trail_sense.shared.andromeda_temp.grow
@@ -65,8 +64,12 @@ class MapLayerBackgroundTask2 {
6564
val taskCopy = synchronized(taskLock) {
6665
tasks.toList()
6766
}
68-
val parallel = ParallelCoroutineRunner()
69-
parallel.run(taskCopy.map { { it(viewBounds, bounds, projection) } })
67+
for (task in taskCopy) {
68+
task(viewBounds, bounds, projection)
69+
}
70+
// TODO: Parallel execution is not working properly - I think it's cancellation related
71+
// val parallel = ParallelCoroutineRunner()
72+
// parallel.run(taskCopy.map { { it(viewBounds, bounds, projection) } })
7073
}
7174
) {
7275

app/src/main/java/com/kylecorry/trail_sense/shared/map_layers/ui/layers/tiles/TileMapLayer.kt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,9 @@ abstract class TileMapLayer<T : ITileSourceSelector>(
4545
shouldReloadTiles = true
4646
}
4747

48-
override fun draw(drawer: ICanvasDrawer, map: IMapView) {
49-
// Avoid drawing while in safe mode
50-
if (SafeMode.isEnabled()) {
51-
return
52-
}
53-
48+
init {
5449
// Load tiles if needed
55-
taskRunner.scheduleUpdate(
56-
drawer.getBounds(45f), // TODO: Cache this
57-
map.mapBounds,
58-
map.mapProjection,
59-
shouldReloadTiles
60-
){ viewBounds: Rectangle, bounds: CoordinateBounds, projection: IMapViewProjection ->
50+
taskRunner.addTask { viewBounds: Rectangle, bounds: CoordinateBounds, projection: IMapViewProjection ->
6151
shouldReloadTiles = false
6252
try {
6353
loader.loadTiles(
@@ -82,6 +72,21 @@ abstract class TileMapLayer<T : ITileSourceSelector>(
8272
shouldReloadTiles = true
8373
}
8474
}
75+
}
76+
77+
override fun draw(drawer: ICanvasDrawer, map: IMapView) {
78+
// Avoid drawing while in safe mode
79+
if (SafeMode.isEnabled()) {
80+
return
81+
}
82+
83+
// Load tiles if needed
84+
taskRunner.scheduleUpdate(
85+
drawer.getBounds(45f), // TODO: Cache this
86+
map.mapBounds,
87+
map.mapProjection,
88+
shouldReloadTiles
89+
)
8590

8691
// Render loaded tiles
8792
synchronized(loader.lock) {

0 commit comments

Comments
 (0)