8000 Detect correct device in the second attempt to create 3-D scene by archmoj · Pull Request #4549 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Detect correct device in the second attempt to create 3-D scene #4549

8000
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 3 commits into from
Feb 12, 2020
Merged
Changes from 1 commit
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
Next Next commit
correct config for device in the second create 3-D scene try
  • Loading branch information
archmoj committed Feb 4, 2020
commit 6929a02804f0a6f071e1048e005da20a04809a06
34 changes: 26 additions & 8 deletions src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ function Scene(options, fullLayout) {

var proto = Scene.prototype;

proto.tryCreatePlot = function() {
proto.prepareOptions = function() {
var scene = this;

var opts = {
canvas: scene.canvas,
gl: scene.gl,
Expand Down Expand Up @@ -132,20 +133,37 @@ proto.tryCreatePlot = function() {
opts.canvas = STATIC_CANVAS;
}

var failed = 0;
return opts;
};

proto.tryCreatePlot = function() {
var scene = this;

var opts = scene.prepareOptions();

var success = true;

try {
scene.glplot = createPlot(opts);
} catch(e) {
failed++;
try { // try second time to fix issue with Chrome 77 https://github.com/plotly/plotly.js/issues/4233
scene.glplot = createPlot(opts);
} catch(e) {
failed++;
if(scene.staticMode) {
success = false;
} else { // try second time
// make fresh object for options
opts = scene.prepareOptions();

try {
// invert preserveDrawingBuffer setup which could be resulted from is-mobile not detecting the right device
opts.glOptions.preserveDrawingBuffer = !opts.glOptions.preserveDrawingBuffer;

scene.glplot = createPlot(opts);
} catch(e) {
success = false;
}
}
}

return failed < 2;
return success;
};

proto.initializeGLCamera = function() {
Expand Down
0