Skip to content

Flash support in modern browsers - #644

Open
po5 wants to merge 11 commits into
rr-:masterfrom
po5:swf
Open

Flash support in modern browsers#644
po5 wants to merge 11 commits into
rr-:masterfrom
po5:swf

Conversation

@po5

@po5 po5 commented Mar 21, 2024

Copy link
Copy Markdown
Collaborator

Makes the booru able to generate thumbnails for any SWF supported by Ruffle, and adds a polyfill for modern browsers.

For non-docker setups, build ruffle's exporter binary with cargo build --release --package=exporter.

This also fixes uploading of all SWF files submitted in #427.
Closes #541.

@CrawlerBleak

CrawlerBleak commented Nov 2, 2024

Copy link
Copy Markdown
Contributor

I think the javascript library should be vendored like the other libraries

const external_js = [
'dompurify',
'js-cookie',
'marked',
'mousetrap',
'nprogress',
'superagent',
'underscore',
];

@po5

po5 commented Mar 28, 2025

Copy link
Copy Markdown
Collaborator Author

If anyone wants to help, all that's left before merging is adding the ruffle exporter to the Docker install.

@CrawlerBleak

Copy link
Copy Markdown
Contributor

If anyone wants to help, all that's left before merging is adding the ruffle exporter to the Docker install.

Are you planning on bundling the JS?

@po5

po5 commented Apr 3, 2025

Copy link
Copy Markdown
Collaborator Author

I'd love to, I'll definitely merge if such a PR ends up on my repo :^)

@CrawlerBleak

Copy link
Copy Markdown
Contributor

Hmm… I'm unable to get the build.js script to work. Here's what I have so far: CrawlerBleak@1d40ff1

I get this error when running ./build.js in the client directory (with or without the --debug flag):

node:internal/errors:541
      throw error;
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
    at Object.writeFileSync (node:fs:2376:5)
    at WriteStream.<anonymous> (/home/user/code/vcs/git/com/github/@/rr-/szurubooru/client/build.js:167:16)
    at WriteStream.emit (node:events:536:35)
    at finish (node:internal/streams/writable:955:10)
    at node:internal/streams/writable:936:13
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v20.19.0

@po5

po5 commented Jul 5, 2025

Copy link
Copy Markdown
Collaborator Author

Getting the ruffle exporter to work in an Alpine docker was much less trivial than I thought, but it's done now. (:
Also committed an important change I forgot to carry over.

ffprobe fails on some swf files and blocks uploading
Comment on lines +82 to +83
"-g",
"gl",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"-g",
"gl",

Error I got with this flag left in:

szurubooru.func.posts Error while processing image.
Error: Ruffle requires hardware acceleration, but no compatible graphics device was found supporting Open GL
Traceback (most recent call last):
  File "szurubooru/func/posts.py", line 650, in update_post_content
    image = images.Image(content)
  File "szurubooru/func/images.py", line 31, in __init__
    self.content = self.swf_to_png()
                   ~~~~~~~~~~~~~~~^^
  File "szurubooru/func/images.py", line 79, in swf_to_png
    return self._execute(
           ~~~~~~~~~~~~~^
        [
        ^
    ...<7 lines>...
        program="exporter",
        ^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "szurubooru/func/images.py", line 310, in _execute
    raise errors.ProcessingError(
        "Error while processing image.\n" + err.decode("utf-8")
    )
szurubooru.errors.ProcessingError: Error while processing image.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Refer to the Docker install, we expect to have mesa-dri-gallium (software OpenGL rendering) and mesa-egl for systems without a GPU. This is necessary as Ruffle uses wgpu, which has no software renderer. I'm following their advice of using something to translate GPU APIs to software.
I don't mind this approach, as it means there is no need to configure anything within szurubooru. If the GPU can be used, it will be.
Please let me know what you think should be done instead. If you're on Mac, it can work without changes with ANGLE. I don't remember exactly why I'm forcing OpenGL rather than letting it use whatever, but I think there was a reason (for the GPU-less case, anyway).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand the question. I don't understand the details. All I know is that it worked for me on Debian 13 without the flag.

@@ -1,13 +1,14 @@
<div class='post-content post-type-<%- ctx.post.type %>'>
<div class='post-content post-type-<%- ctx.post.type %>' style='<%- ctx.post.type === 'flash' ? 'background-image: url('+ctx.post.thumbnailUrl+')' : '' %>'>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This background image needs to be unset when the flash object is played, otherwise you run into this:

Screen.Recording.2026-05-20.at.02.14.45.mov

Comment thread client/html/index.htm
<div id='content-holder'></div>
<script type='text/javascript' src='js/vendor.min.js'></script>
<script type='text/javascript' src='js/app.min.js'></script>
<script type='text/javascript' src='https://unpkg.com/@ruffle-rs/ruffle' async></script>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be vendored (as discussed, sorry).

Comment on lines +303 to 305
"Failed to execute {program} command (cli=%r, err=%r)".format(program=program),
" ".join(shlex.quote(arg) for arg in cli),
err,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor nitpick:

Suggested change
"Failed to execute {program} command (cli=%r, err=%r)".format(program=program),
" ".join(shlex.quote(arg) for arg in cli),
err,
"Failed to execute %s command (cli=%r, err=%r)",
program,
" ".join(shlex.quote(arg) for arg in cli),
err,

@po5

po5 commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

@CrawlerBleak Thank you the the review, I will address the issues when I can.

@CrawlerBleak

Copy link
Copy Markdown
Contributor

I took a stab at taking my own advice: po5#4

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

Successfully merging this pull request may close these issues.

Support for Flash swf files after flash having support removed from modern browsers

2 participants