Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
983ae4f8
Commit
983ae4f8
authored
3 years ago
by
dsehnal
Browse files
Options
Downloads
Patches
Plain Diff
PluginFeatureDetection and disable WBOIT in Safari
parent
0d4f6bb5
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-0
2 additions, 0 deletions
CHANGELOG.md
src/mol-plugin/config.ts
+3
-27
3 additions, 27 deletions
src/mol-plugin/config.ts
src/mol-plugin/features.ts
+37
-0
37 additions, 0 deletions
src/mol-plugin/features.ts
with
42 additions
and
27 deletions
CHANGELOG.md
+
2
−
0
View file @
983ae4f8
...
...
@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
## [Unreleased]
-
Add
``PluginFeatureDetection``
and disable WBOIT in Safari 15.
## [v3.0.0-dev.7] - 2021-12-20
-
Reduce number of created programs/shaders
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/config.ts
+
3
−
27
View file @
983ae4f8
...
...
@@ -10,6 +10,7 @@ import { PluginContext } from './context';
import
{
PdbDownloadProvider
}
from
'
../mol-plugin-state/actions/structure
'
;
import
{
EmdbDownloadProvider
}
from
'
../mol-plugin-state/actions/volume
'
;
import
{
StructureRepresentationPresetProvider
}
from
'
../mol-plugin-state/builder/structure/representation-preset
'
;
import
{
PluginFeatureDetection
}
from
'
./features
'
;
export
class
PluginConfigItem
<
T
=
any
>
{
toString
()
{
return
this
.
key
;
}
...
...
@@ -19,31 +20,6 @@ export class PluginConfigItem<T = any> {
function
item
<
T
>
(
key
:
string
,
defaultValue
?:
T
)
{
return
new
PluginConfigItem
(
key
,
defaultValue
);
}
export
function
preferWebGl1
()
{
if
(
typeof
navigator
===
'
undefined
'
||
typeof
window
===
'
undefined
'
)
return
false
;
// WebGL2 isn't working in MacOS 12.0.1 Safari 15.1, 15.2. It is working in Safari 15.4 tech preview, so disabling all versions before that.
// prefer webgl 1 based on the userAgent substring
const
unpportedSafariVersions
=
[
'
Version/15.1 Safari
'
,
'
Version/15.2 Safari
'
,
'
Version/15.3 Safari
'
];
if
(
unpportedSafariVersions
.
some
(
v
=>
navigator
.
userAgent
.
indexOf
(
v
)
>
0
))
{
return
true
;
}
// Check for iOS device which enabled WebGL2 recently but it doesn't seem
// to be full up to speed yet.
// adapted from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
const
isIOS
=
/iPad|iPhone|iPod/
.
test
(
navigator
.
userAgent
);
const
isAppleDevice
=
navigator
.
userAgent
.
includes
(
'
Macintosh
'
);
const
isTouchScreen
=
navigator
.
maxTouchPoints
>=
4
;
// true for iOS 13 (and hopefully beyond)
return
!
(
window
as
any
).
MSStream
&&
(
isIOS
||
(
isAppleDevice
&&
isTouchScreen
));
}
export
const
PluginConfig
=
{
item
,
General
:
{
...
...
@@ -53,10 +29,10 @@ export const PluginConfig = {
PixelScale
:
item
(
'
plugin-config.pixel-scale
'
,
1
),
PickScale
:
item
(
'
plugin-config.pick-scale
'
,
0.25
),
PickPadding
:
item
(
'
plugin-config.pick-padding
'
,
3
),
EnableWboit
:
item
(
'
plugin-config.enable-wboit
'
,
true
),
EnableWboit
:
item
(
'
plugin-config.enable-wboit
'
,
PluginFeatureDetection
.
wboit
),
// as of Oct 1 2021, WebGL 2 doesn't work on iOS 15.
// TODO: check back in a few weeks to see if it was fixed
PreferWebGl1
:
item
(
'
plugin-config.prefer-webgl1
'
,
preferWebGl1
()
),
PreferWebGl1
:
item
(
'
plugin-config.prefer-webgl1
'
,
PluginFeatureDetection
.
preferWebGl1
),
},
State
:
{
DefaultServer
:
item
(
'
plugin-state.server
'
,
'
https://webchem.ncbr.muni.cz/molstar-state
'
),
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/features.ts
0 → 100644
+
37
−
0
View file @
983ae4f8
/**
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
export
const
PluginFeatureDetection
=
{
get
preferWebGl1
()
{
if
(
typeof
navigator
===
'
undefined
'
||
typeof
window
===
'
undefined
'
)
return
false
;
// WebGL2 isn't working in MacOS 12.0.1 Safari 15.1, 15.2. It is working in Safari 15.4 tech preview, so disabling all versions before that.
// prefer webgl 1 based on the userAgent substring
const
unpportedSafariVersions
=
[
'
Version/15.1 Safari
'
,
'
Version/15.2 Safari
'
,
'
Version/15.3 Safari
'
];
if
(
unpportedSafariVersions
.
some
(
v
=>
navigator
.
userAgent
.
indexOf
(
v
)
>
0
))
{
return
true
;
}
// Check for iOS device which enabled WebGL2 recently but it doesn't seem
// to be full up to speed yet.
// adapted from https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
const
isIOS
=
/iPad|iPhone|iPod/
.
test
(
navigator
.
userAgent
);
const
isAppleDevice
=
navigator
.
userAgent
.
includes
(
'
Macintosh
'
);
const
isTouchScreen
=
navigator
.
maxTouchPoints
>=
4
;
// true for iOS 13 (and hopefully beyond)
return
!
(
window
as
any
).
MSStream
&&
(
isIOS
||
(
isAppleDevice
&&
isTouchScreen
));
},
get
wboit
()
{
if
(
typeof
navigator
===
'
undefined
'
||
typeof
window
===
'
undefined
'
)
return
true
;
// disable Wboit in Safari 15
return
!
/Version
\/
15.
\d
Safari/
.
test
(
navigator
.
userAgent
);
}
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment