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

Unify renderMode options and add missing documentation #118

Merged
merged 4 commits into from
Jan 31, 2022

Conversation

TheOneric
Copy link
Member

The renames are not in line with what is currently used in jellyfin. However fast doesn't make much sense for the lossy mode and normal also isn't a good name for the JS-blending mode, especially since we want to change the default soon.

This will make future diffs easier to read.
TheOneric and others added 3 commits January 27, 2022 08:11
This better matches what the modes actually do.
Currently mostly internal apart from the lossy mode being referred to as
"fast" in the README, but the next commit will expose the internal names
to the public.
This does not change the existing option names, which are
already closer to the new than the old names.
To preserve backwards compatibility, the old option names
are still evaluated, but only at a lower priority.
Fixes oversights in commits 49d86ec
(targetFps and libassMemoryLimit) and
030aaa8 (libassGlyphLimit).
Copy link
Collaborator

@TFSThiagoBR98 TFSThiagoBR98 left a comment

Choose a reason for hiding this comment

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

LGTM

@dmitrylyzo
Copy link
Contributor

Real default targetFps:

But it can also be specified here (as in that renderAhead PR):

self.targetFps = options.targetFps || undefined;

just to unify the options and not to clog that feature

@TheOneric
Copy link
Member Author

Real default targetFps:

// src/post-worker.js, line 9:
self.targetFps = 30; 

Can you elaborate on what you think should be changed? The doc-commit does list 30 as the default.

@dmitrylyzo
Copy link
Contributor

dmitrylyzo commented Jan 28, 2022

Can you elaborate on what you think should be changed? The doc-commit does list 30 as the default.

https://github.com/jellyfin/JavascriptSubtitlesOctopus/blob/f4625ac313b318bd5d2e0ae18679ff516370bae6/src/subtitles-octopus.js#L22

But that's because renderAhead started using targetFps in the subtitles-octopus.js.

@TheOneric
Copy link
Member Author

[Later commits of #111 setting the default already in subtitles-octopus.js.] But that's because renderAhead started using targetFps in the subtitles-octopus.js.

I'm afraid I am still not sure what change you are suggesting. The only commit relating to targetFps here is the documentation-fix. It lists 30 as the default value. While in src/subtitles-octopus.js the fallback is to undefined, the value is not used in src/subtitles-octopus.js (yet) and in src/post-worker.js a value of undefined will be made to fall back to 30, so 30 should indeed be the default value. Did I miss something?

Do you perhaps, want the default value already being set in src/subtitles-octopus.js? If so, I already planned to do this in the follow-up series to this updating the default values for consistency with other options; but this has no place in a commit adding missing documentation.

@dmitrylyzo
Copy link
Contributor

Do you perhaps, want the default value already being set in src/subtitles-octopus.js?

Yes.

-    self.targetFps = options.targetFps || undefined;
+    self.targetFps = options.targetFps || 30;

But it is not currently used in subtitles-octopus.js, so it is probably not necessary to change this now.

If so, I already planned to do this in the follow-up series to this updating the default values for consistency with other options; but this has no place in a commit adding missing documentation.

👍

@TheOneric TheOneric merged commit 37ae5bc into libass:master Jan 31, 2022
@TheOneric TheOneric deleted the options_rendermode branch January 31, 2022 00:24
@dmitrylyzo
Copy link
Contributor

dmitrylyzo commented Jan 31, 2022

@TheOneric If renderMode is not valid, the renderer runs discontinuously, probably trying to output an error message.
Just noticed this while I was porting the empty fix.
Maybe it would be better to fix the mode in the options block?

You may also be interested in https://github.com/WeebDataHoarder/JavascriptSubtitlesOctopus/blob/ea80135ebe80d3fae85f0a88e5f38801335d563c/src/subtitles-octopus.js#L5-L8
WeebDataHoarder@ea80135

@TheOneric
Copy link
Member Author

If renderMode is not valid, the renderer runs discontinuously, probably trying to output an error message.

When I tested this the error message was only printed on intital page load, resize and playback resume after pause. While playback was active I didn't get any more error messages.

Maybe it would be better to fix the mode in the options block?

That would require duplicating the full list of valid renderModes, which is not great. A simpler way to avoid repeated errors is to just override the stored renderMode after outputting the message. (Or alternatively if changing the renderMode during playback is not supported or planned to be supported: run getRenderMethod only once during init and store the result.)

@dmitrylyzo
Copy link
Contributor

dmitrylyzo commented Jan 31, 2022

When I tested this the error message was only printed on intital page load, resize and playback resume after pause. While playback was active I didn't get any more error messages.

I didn't have them either - it was quietly lagging. Only 4 times at the start.

That would require duplicating the full list of valid renderModes, which is not great.

How about a lookup?

self.renderModes = {
    'js-blend': self.render,
    'lossy': self.lossyRender,
    'wasm-blend': self.blendRender
};

I think renderMode can also be defined with a custom setter where you can check the mode - if we need to change it on-the-fly.

@TheOneric
Copy link
Member Author

You may also be interested in https://github.com/WeebDataHoarder/JavascriptSubtitlesOctopus/blob/ea80135ebe80d3fae85f0a88e5f38801335d563c/src/subtitles-octopus.js#L5-L8
WeebDataHoarder/JavascriptSubtitlesOctopus@ea80135

The comment claiming Safari not supporting the function doesn't seem to be accurate (anymore), assuming Safari is using up-to-date WebKit. With WebKitGTK 2.34.4 createImageBitmap is a function calling native code:

> createImageBitmap
< function createImageBitmap() {
    [native code]
}
> typeof createImageBitmap
< "function"

Is there another reason lossy doesn't work in Safari (meaning the check would have to be different) or does this only apply to old versions and other BrowserEngines as used eg by SmartTVs? Fwiw with the aforementioned WebkitGTK the Brotli sample using the lossy renderer plays fine for me.

@dmitrylyzo
Copy link
Contributor

dmitrylyzo commented Feb 1, 2022

https://webostv.developer.lge.com/discover/specifications/web-engine/
webOS 1.2 emulator (WebKit 538.2) - no Promise, no createImageBitmap.
webOS 2.0 emulator (WebKit 537.41) - has Promise (#122 (comment)), no createImageBitmap.
webOS 3.0 emulator (Chrome 38) - has Promise, no createImageBitmap.
webOS 4.0 emulator (Chrome 53) - has Promise, has createImageBitmap.

It is also better to check window.createImageBitmap. Otherwise you get ReferenceError: Can't find variable: createImageBitmap.
Or use try/catch.
Using typeof fixes that.

TheOneric added a commit to TheOneric/JavascriptSubtitlesOctopus that referenced this pull request Feb 6, 2022
Supposedly[1] the fallback path is called often enough
to cause performance degradation with invalid values;
fix up those values so this path is only taken once.

[1]: libass#118 (comment)
TheOneric added a commit to TheOneric/JavascriptSubtitlesOctopus that referenced this pull request Feb 7, 2022
Supposedly[1] the fallback path is called often enough
to cause performance degradation with invalid values;
fix up those values so this path is only taken once.

[1]: libass#118 (comment)
TFSThiagoBR98 pushed a commit to TFSThiagoBR98/JavascriptSubtitlesOctopus that referenced this pull request Feb 14, 2022
Supposedly[1] the fallback path is called often enough
to cause performance degradation with invalid values;
fix up those values so this path is only taken once.

[1]: libass#118 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants