Skip to content

Commit d9c3679

Browse files
chrisgervangclaude
andcommitted
test(mapbox): Use isolated WebGL device for overlaid mode tests
Overlaid mode tests create their own Deck instances which can cause GL context corruption when sharing contexts across tests. Using an isolated WebGLDevice for these tests prevents hangs in the test suite. Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
1 parent ccf5522 commit d9c3679

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

modules/test-utils/src/utils/setup-gl.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// SPDX-License-Identifier: MIT
33
// Copyright (c) vis.gl contributors
44

5-
import {CanvasContextProps} from '@luma.gl/core';
6-
import {WebGLDevice} from '@luma.gl/webgl';
75
import {webglDevice, NullDevice} from '@luma.gl/test-utils';
86

97
export const device = webglDevice || new NullDevice({});

test/modules/mapbox/mapbox-overlay.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ import {ScatterplotLayer} from '@deck.gl/layers';
88
import {MapboxOverlay} from '@deck.gl/mapbox';
99
import {_GlobeView as GlobeView, MapView, Widget} from '@deck.gl/core';
1010
import type {WidgetPlacement} from '@deck.gl/core';
11+
import {WebGLDevice} from '@luma.gl/webgl';
1112

1213
import {objectEqual} from './mapbox-layer.spec';
1314
import MockMapboxMap from './mapbox-gl-mock/map';
1415
import {DEFAULT_PARAMETERS} from './fixtures';
1516

17+
// Create an isolated device for overlaid mode tests to prevent GL context corruption
18+
const overlaidTestDevice = new WebGLDevice({createCanvasContext: {width: 1, height: 1}});
19+
1620
// Simple test widget for testing MapboxOverlay widget support
1721
class TestWidget extends Widget<{placement?: WidgetPlacement; viewId?: string | null}> {
1822
static defaultProps = {
@@ -58,6 +62,7 @@ test('MapboxOverlay#overlaid', t => {
5862
zoom: 14
5963
});
6064
const overlay = new MapboxOverlay({
65+
device: overlaidTestDevice,
6166
layers: [new ScatterplotLayer()]
6267
});
6368

@@ -120,7 +125,9 @@ test('MapboxOverlay#overlaidNoIntitalLayers', t => {
120125
center: {lng: -122.45, lat: 37.78},
121126
zoom: 14
122127
});
123-
const overlay = new MapboxOverlay({});
128+
const overlay = new MapboxOverlay({
129+
device: overlaidTestDevice
130+
});
124131

125132
map.addControl(overlay);
126133

@@ -510,6 +517,7 @@ test('MapboxOverlay#widgets - regular widgets render in deck container', t => {
510517

511518
const widget = new TestWidget({id: 'regular-widget', placement: 'top-right'});
512519
const overlay = new MapboxOverlay({
520+
device: overlaidTestDevice,
513521
layers: [new ScatterplotLayer()],
514522
widgets: [widget]
515523
});
@@ -533,6 +541,7 @@ test('MapboxOverlay#widgets - viewId:mapbox widgets wrapped as IControl', t => {
533541

534542
const widget = new TestWidget({id: 'mapbox-widget', viewId: 'mapbox', placement: 'top-right'});
535543
const overlay = new MapboxOverlay({
544+
device: overlaidTestDevice,
536545
layers: [new ScatterplotLayer()],
537546
widgets: [widget]
538547
});
@@ -566,6 +575,7 @@ test('MapboxOverlay#widgets - mixed widgets', t => {
566575
});
567576

568577
const overlay = new MapboxOverlay({
578+
device: overlaidTestDevice,
569579
layers: [new ScatterplotLayer()],
570580
widgets: [regularWidget, mapboxWidget1, mapboxWidget2]
571581
});
@@ -593,6 +603,7 @@ test('MapboxOverlay#widgets - setProps updates widget controls', t => {
593603

594604
const widget1 = new TestWidget({id: 'widget1', viewId: 'mapbox', placement: 'top-right'});
595605
const overlay = new MapboxOverlay({
606+
device: overlaidTestDevice,
596607
layers: [new ScatterplotLayer()],
597608
widgets: [widget1]
598609
});

0 commit comments

Comments
 (0)