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

Resize makes subtitle disappear #156

Open
fifv opened this issue Feb 23, 2023 · 1 comment
Open

Resize makes subtitle disappear #156

fifv opened this issue Feb 23, 2023 · 1 comment

Comments

@fifv
Copy link

fifv commented Feb 23, 2023

Due to weird chromium behavior, Alt+Tab at fullscreen resizes the window a bit, then subtitle disappears.

The resize event is handled by resizeWithTimeout() in subtitles-octopus.js, which is:

self.resizeWithTimeout = function () {
    self.resize();
    setTimeout(self.resize, 100);
};

I don't understand the purpose to resize twice, but the resize() call do this:

// --snip--
if (
  self.canvas.width != width ||
  self.canvas.height != height ||
  self.canvas.style.top != top ||
  self.canvas.style.left != left
) {
// --snip--
    self.canvas.width = width;
    self.canvas.height = height;
// --snip--
}
// --snip--

The canvas will clear all contents and context if its width and height is assigned, which causes subtitle disappear.

And these conditions in the if seems not work, for width and height are float while self.canvas.width and self.canvas.height are int.

One workaround:

if (
    self.canvas.width != Math.floor(width) ||
    self.canvas.height != Math.floor(height) ||
    self.canvas.style.top != top + 'px' ||
    self.canvas.style.left != left + 'px'
}

One more workaround:

just remove setTimeout(self.resize, 100);, this works fine for me.

One more workaround:

In src/post-worker.js, find function onMessageFromMainEmscriptenThread(), then switch ... case 'canvas', then self.getRenderMethod()();, change it to:

`self.getRenderMethod()(true);` 

to force render when resizing.

@fifv
Copy link
Author

fifv commented Feb 23, 2023

I didn't notice this PR when I was writing the issue #132
But hope these will help someone. :)

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

No branches or pull requests

1 participant