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

chore(mapbox) use props.device instead of props.gl #8554

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/mapbox/src/deck-utils.ts
@@ -1,5 +1,6 @@
import {Deck, WebMercatorViewport, MapView, _flatten as flatten} from '@deck.gl/core';
import type {DeckProps, MapViewState, Layer} from '@deck.gl/core';
import {WebGLDevice} from '@luma.gl/webgl';
import type MapboxLayer from './mapbox-layer';
import type {Map} from 'mapbox-gl';

Expand Down Expand Up @@ -50,7 +51,7 @@ export function getDeckInstance({

let deckInstance: Deck;

if (!deck || deck.props.gl === gl) {
if (!deck || (deck.props.device instanceof WebGLDevice && deck.props.device.gl === gl)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the instanceof check here is just to keep Typescript happy? What happens if it is a WebGPUDevice? Would it maybe be safer to check for WebGPUDevice at the start of this function and exit early with a warning?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break the check. Note you are checking deck.props which is constructed below at line 59. Only gl is passed, not device.

// If deck isn't defined (Internal MapboxLayer use case),
// or if deck is defined and is using the WebGLContext created by mapbox (MapboxOverlay and External MapboxLayer use case),
// block deck from setting the canvas size, and use the map's viewState to drive deck.
Expand Down