This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
HARP-12989 Fix extra console entries in tests #1972
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b6e4704
HARP-12989 Fix extra console entries in tests
nzjony b5ddf2e
HARP-12989 Fixing deprecated warning for min/max ZoomLevel
nzjony 48e8399
HARP-12989 Removing some more loggers
nzjony 2b056c8
Code review fixes
nzjony 688399a
More code review fixes
nzjony ecd16a6
Wait for mapView to finish loading before disposing
nzjony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,16 @@ export class MapViewEnvironment { | |
private m_skyBackground?: SkyBackground; | ||
private m_createdLights?: THREE.Light[]; | ||
private m_overlayCreatedLights?: THREE.Light[]; | ||
private readonly m_backgroundDSPromise: Promise<void> | undefined; | ||
private readonly m_backgroundDataSource?: BackgroundDataSource; | ||
|
||
constructor(private readonly m_mapView: MapView, options: MapViewEnvironmentOptions) { | ||
this.m_fog = new MapViewFog(this.m_mapView.scene); | ||
if (options.addBackgroundDatasource !== false) { | ||
this.m_backgroundDataSource = new BackgroundDataSource(); | ||
this.m_mapView.addDataSource(this.m_backgroundDataSource); | ||
this.m_backgroundDSPromise = this.m_mapView.addDataSource(this.m_backgroundDataSource); | ||
} else { | ||
this.m_backgroundDSPromise = undefined; | ||
} | ||
if ( | ||
options.backgroundTilingScheme !== undefined && | ||
|
@@ -72,6 +75,15 @@ export class MapViewEnvironment { | |
return this.m_fog; | ||
} | ||
|
||
/** | ||
* Required to be able to wait for this DataSource to be added, if not, the MapViewTest.ts will | ||
* complain because we then call update() once the MapView is disposed. | ||
* @internal | ||
*/ | ||
get backgroundDataSourcePromise(): Promise<void> | undefined { | ||
return this.m_backgroundDSPromise; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can and should avoid exposing this implementation detail, see my comments in MapViewTest. |
||
updateBackgroundDataSource() { | ||
if (this.m_backgroundDataSource) { | ||
this.m_backgroundDataSource.updateStorageLevelOffset(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
import { PerformanceTimer, Task, TaskQueue } from "@here/harp-utils"; | ||
import THREE = require("three"); | ||
|
||
import { TileTaskGroups } from "./MapView"; | ||
import { MapView, TileTaskGroups } from "./MapView"; | ||
import { PerformanceStatistics } from "./Statistics"; | ||
|
||
const DEFAULT_MAX_FPS = 60; | ||
|
@@ -17,7 +17,7 @@ export class MapViewTaskScheduler extends THREE.EventDispatcher { | |
private readonly m_taskQueue: TaskQueue; | ||
private m_throttlingEnabled: boolean = false; | ||
|
||
constructor(private m_maxFps: number = DEFAULT_MAX_FPS) { | ||
constructor(private m_maxFps: number = DEFAULT_MAX_FPS, private readonly m_mapView: MapView) { | ||
nzjony marked this conversation as resolved.
Show resolved
Hide resolved
|
||
super(); | ||
this.m_taskQueue = new TaskQueue({ | ||
groups: [TileTaskGroups.FETCH_AND_DECODE, TileTaskGroups.CREATE], | ||
|
@@ -77,6 +77,10 @@ export class MapViewTaskScheduler extends THREE.EventDispatcher { | |
let numItemsLeft = this.taskQueue.numItemsLeft(); | ||
currentFrameEvent?.setValue("TaskScheduler.numPendingTasks", numItemsLeft); | ||
|
||
// Needed for tests that dispose but that still have running tasks after MapView disposed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Otherwise the tasks are executed on a mapView that has disposed and the update method sends long of messages to the console. |
||
const mapViewAlive = () => { | ||
return !this.m_mapView.disposed; | ||
}; | ||
if (this.throttlingEnabled) { | ||
// get the available time in this frame to achieve a max fps rate | ||
let availableTime = this.spaceInFrame(frameStartTime); | ||
|
@@ -90,6 +94,9 @@ export class MapViewTaskScheduler extends THREE.EventDispatcher { | |
counter++; | ||
// create a processing condition for the tasks | ||
function shouldProcess(task: Task) { | ||
if (!mapViewAlive()) { | ||
return false; | ||
} | ||
// if there is a time estimate use it, otherwise default to 1 ms | ||
// TODO: check whats a sane default, 1 seems to do it for now | ||
availableTime -= | ||
|
@@ -132,12 +139,12 @@ export class MapViewTaskScheduler extends THREE.EventDispatcher { | |
//if throttling is disabled, process all pending tasks | ||
this.m_taskQueue.processNext( | ||
TileTaskGroups.CREATE, | ||
undefined, | ||
mapViewAlive, | ||
this.m_taskQueue.numItemsLeft(TileTaskGroups.CREATE) | ||
); | ||
this.m_taskQueue.processNext( | ||
TileTaskGroups.FETCH_AND_DECODE, | ||
undefined, | ||
mapViewAlive, | ||
this.m_taskQueue.numItemsLeft(TileTaskGroups.FETCH_AND_DECODE) | ||
); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to capture this and make it external so that it can be
await
ed in the test to ensure that it is connected before we continue test execution.