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

WebGL 2.0 がサポートされているかチェックする #390

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

naogify
Copy link
Member

@naogify naogify commented Apr 23, 2024

WebGL 2.0 がサポートされているかチェックする機能を追加しました。

WebGL 2.0 を無効にした場合、Chrome でグラフィックアクセラレーションを無効にした場合は以下の表示がされます。

スクリーンショット 2024-04-23 17 43 12

Closes #389

@naogify naogify requested review from a team, keichan34, sugama-satsuki and shi-works and removed request for a team April 23, 2024 08:36
@naogify naogify marked this pull request as draft April 23, 2024 08:40
@naogify naogify marked this pull request as ready for review April 23, 2024 08:50
Copy link
Member

@keichan34 keichan34 left a comment

Choose a reason for hiding this comment

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

手法をちょっと変更したいです、、。
今は新しい webgl2 コンテキストを新しく作ろうとしているけど、この手法ではいくつかの問題があるのかなと思います:

  • 余計にコンテキストを作ってしまう(例えば Chrome は16個まで、古い順から削除される)
  • これが通ったといっても地図が表示されるか、というのも完全にわかるわけではない。。

ので、理想的な実装は、地図を初期化しようとするけど、何かしらの問題で失敗した時にエラーを表示する。例えば、コンテキストが起動できなくて new maplibregl.Map(...) で例外が発火されたら、それをキャッチしてユーザーにわかりやすい表示にする。

今回、alertで出してるけど、alertだと複数地図ある時にスパムっぽくなるし、場合によって地図がメインじゃないサイトに邪魔になる可能性にもなるので、地図があるはずの場所にHTMLで表示してください。

イメージとしてはGoogleMapsのエラーメッセージ(リクエスト上限足したらエラー画面が出るような設定はembed APIでも入っているはず、、)の方が親切だと思います。
Screenshot 2024-04-24 at 9 18 35

@@ -46,6 +46,12 @@ export default class GeoloniaMap extends maplibregl.Map {
private __styleExtensionLoadRequired: boolean;

constructor(params: string | GeoloniaMapOptions) {

if (!isWebgl2Supported()) {
console.warn('[Geolonia] WebGL 2.0 is not supported, or graphics acceleration is disabled.');
Copy link
Member

Choose a reason for hiding this comment

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

これは明示的に入れているので、eslintのワーニングが出ないようにコメントを入れてください

naogify and others added 3 commits May 10, 2024 12:18
When an error is thrown in renderGeoloniaMap(), subsequent maps will fail
to render and show the error dialog.

Additionally, the try/catch was shortened to include only the new map (super(options))
and re-throws the initial error object, because at that point the map is useless and
should not be used normally. If the error was not rethrown, code using the map
wouldn't know if the map was valid or not.
@naogify
Copy link
Member Author

naogify commented May 10, 2024

以下のように地図表示エリアに警告を表示するようにしました。

PC
スクリーンショット 2024-05-10 15 44 35

モバイル
スクリーンショット 2024-05-10 15 43 53

確認方法

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebGL/WebGL2などのパーフォマンスが出ない時にエラーメッセージ・警告を表示
3 participants