Skip to content

Resize makes subtitle disappear #156

Open
@fifv

Description

@fifv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions