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

Add back synced frame method and use it for triggerRepaint. #4535

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
14 changes: 9 additions & 5 deletions src/ui/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3067,7 +3067,7 @@

// update terrain stuff
if (this.terrain) {
this.terrain.sourceCache.update(this.transform, this.terrain);

Check failure on line 3070 in src/ui/map.ts

View workflow job for this annotation

GitHub Actions / Unit tests and Coverage

marker › Marker changes opacity behind terrain and when terrain is removed

TypeError: Cannot read properties of undefined (reading 'update') at Map._render (src/ui/map.ts:3070:38) at src/ui/map.ts:3215:26

Check failure on line 3070 in src/ui/map.ts

View workflow job for this annotation

GitHub Actions / Unit tests and Coverage

marker › Removes an open popup when going behind 3d terrain

TypeError: Cannot read properties of undefined (reading 'update') at Map._render (src/ui/map.ts:3070:38) at src/ui/map.ts:3215:26
this.transform.minElevationForCurrentTile = this.terrain.getMinTileElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
if (!this._elevationFreeze) {
this.transform.elevation = this.terrain.getElevationForLngLatZoom(this.transform.center, this.transform.tileZoom);
Expand Down Expand Up @@ -3207,11 +3207,15 @@
triggerRepaint() {
if (this.style && !this._frameRequest) {
this._frameRequest = new AbortController();
browser.frameAsync(this._frameRequest).then((paintStartTimeStamp: number) => {
PerformanceUtils.frame(paintStartTimeStamp);
this._frameRequest = null;
this._render(paintStartTimeStamp);
}).catch(() => {}); // ignore abort error
browser.frame(
this._frameRequest,
(paintStartTimeStamp) => {
PerformanceUtils.frame(paintStartTimeStamp);
this._frameRequest = null;
this._render(paintStartTimeStamp);
},
() => {}
);
}
}

Expand Down
14 changes: 9 additions & 5 deletions src/util/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ export const browser = {
*/
now,

frame(abortController: AbortController, fn: (paintStartTimestamp: number) => void, reject): void {
const frame = requestAnimationFrame(fn);
abortController.signal.addEventListener('abort', () => {
cancelAnimationFrame(frame);
reject(createAbortError());
});
},

frameAsync(abortController: AbortController): Promise<number> {
return new Promise((resolve, reject) => {
const frame = requestAnimationFrame(resolve);
abortController.signal.addEventListener('abort', () => {
cancelAnimationFrame(frame);
reject(createAbortError());
});
this.frame(abortController, resolve, reject);
});
},

Expand Down
Loading