Skip to content

Fix safari chart rendering issues. #6303

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

Merged
merged 1 commit into from
Apr 10, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ $_data_table_initial_height: 100px;
}

.chart-container {
display: flex;
flex-direction: column;
flex-grow: 1;
overflow: hidden;
resize: vertical;
Expand All @@ -109,8 +111,7 @@ $_data_table_initial_height: 100px;
}

line-chart {
display: block;
height: 100%;
flex-grow: 1;
}
}

Expand Down
1 change: 1 addition & 0 deletions tensorboard/webapp/widgets/line_chart_v2/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ tf_ts_library(
visibility = ["//tensorboard:internal"],
deps = [
":internal_types",
"@npm//@types/offscreencanvas",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class ThreeRenderer implements ObjectRenderer<CacheValue> {
onContextLost?: EventListener
) {
if (
ChartUtils.isOffscreenCanvasSupported() &&
ChartUtils.isWebGl2OffscreenCanvasSupported() &&
canvas instanceof OffscreenCanvas
) {
// THREE.js require the style object which Offscreen canvas lacks.
Expand Down
11 changes: 8 additions & 3 deletions tensorboard/webapp/widgets/line_chart_v2/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ function isWebGl2Supported(): boolean {
return cachedIsWebGl2Supported;
}

function isOffscreenCanvasSupported(): boolean {
return self.hasOwnProperty('OffscreenCanvas');
function isWebGl2OffscreenCanvasSupported(): boolean {
if (!self.hasOwnProperty('OffscreenCanvas')) {
return false;
}
// Safari 16.4 rolled out OffscreenCanvas support but without webgl2 support.
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

const context = new OffscreenCanvas(0, 0).getContext('webgl2');
return Boolean(context);
}

function arePolylinesEqual(lineA: Polyline, lineB: Polyline) {
Expand Down Expand Up @@ -72,7 +77,7 @@ function areExtentsEqual(extentA: Extent, extentB: Extent): boolean {
export const ChartUtils = {
convertRectToExtent,
isWebGl2Supported,
isOffscreenCanvasSupported,
isWebGl2OffscreenCanvasSupported,
arePolylinesEqual,
areExtentsEqual,
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ limitations under the License.

:host {
contain: strict;
display: inline-block;
display: flex;
flex-direction: column;

::ng-deep .line-chart:has(.horizontal-prospective-area:hover) {
.x-axis {
Expand All @@ -37,6 +38,7 @@ limitations under the License.
.container {
background: inherit;
display: grid;
flex-grow: 1;
height: 100%;
overflow: hidden;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class LineChartComponent

const useWorker =
rendererType !== RendererType.SVG &&
ChartUtils.isOffscreenCanvasSupported();
ChartUtils.isWebGl2OffscreenCanvasSupported();
const klass = useWorker ? WorkerChart : ChartImpl;
this.lineChart = new klass(params);
}
Expand Down