Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

#21451 Fix WebGL disabled error message #10589

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 7 additions & 4 deletions src/components/views/location/LocationPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ class LocationPicker extends React.Component<ILocationPickerProps, IState> {
}
} catch (e) {
logger.error("Failed to render map", e);
const errorType =
(e as Error)?.message === LocationShareError.MapStyleUrlNotConfigured
? LocationShareError.MapStyleUrlNotConfigured
: LocationShareError.Default;
const errorMessage = (e as Error)?.message;
rashmitpankhania marked this conversation as resolved.
Show resolved Hide resolved
let errorType;
if(errorMessage === LocationShareError.MapStyleUrlNotConfigured)
errorType = LocationShareError.MapStyleUrlNotConfigured;
else if(errorMessage.includes('Failed to initialize WebGL'))
errorType = LocationShareError.WebGLNotEnabled;
else errorType = LocationShareError.Default;
this.setState({ error: errorType });
}
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@
"You may need to manually permit %(brand)s to access your microphone/webcam": "You may need to manually permit %(brand)s to access your microphone/webcam",
"This homeserver is not configured to display maps.": "This homeserver is not configured to display maps.",
"This homeserver is not configured correctly to display maps, or the configured map server may be unreachable.": "This homeserver is not configured correctly to display maps, or the configured map server may be unreachable.",
"WebGL is required for this site, please enable it in your browser settings.": "WebGL is required for this site, please enable it in your browser settings.",
"Toggle attribution": "Toggle attribution",
"Map feedback": "Map feedback",
"Enter fullscreen": "Enter fullscreen",
Expand Down
3 changes: 3 additions & 0 deletions src/utils/location/LocationShareErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { _t } from "../../languageHandler";
export enum LocationShareError {
MapStyleUrlNotConfigured = "MapStyleUrlNotConfigured",
MapStyleUrlNotReachable = "MapStyleUrlNotReachable",
WebGLNotEnabled = "WebGLNotEnabled",
Default = "Default",
}

Expand All @@ -27,6 +28,8 @@ export const getLocationShareErrorMessage = (errorType?: LocationShareError): st
case LocationShareError.MapStyleUrlNotConfigured:
return _t("This homeserver is not configured to display maps.");
case LocationShareError.MapStyleUrlNotReachable:
case LocationShareError.WebGLNotEnabled:
return _t("WebGL is required for this site, please enable it in your browser settings.")
rashmitpankhania marked this conversation as resolved.
Show resolved Hide resolved
default:
return _t(
`This homeserver is not configured correctly to display maps, ` +
Expand Down
12 changes: 12 additions & 0 deletions test/components/views/location/LocationPicker-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ describe("LocationPicker", () => {
expect(getByText("This homeserver is not configured to display maps.")).toBeInTheDocument();
});

it("displays error when WebGl is not enabled", () => {
// suppress expected error log
jest.spyOn(logger, "error").mockImplementation(() => {});
mocked(findMapStyleUrl).mockImplementation(() => {
throw new Error("Failed to initialize WebGL");
});

const { getByText } = getComponent();

expect(getByText("WebGL is required for this site, please enable it in your browser settings.")).toBeInTheDocument();
});

it("displays error when map setup throws", () => {
// suppress expected error log
jest.spyOn(logger, "error").mockImplementation(() => {});
Expand Down