Skip to content

Add support for 3D/CAD file formats preview #34794

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kerwin612
Copy link
Member

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 20, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/dependencies modifies/frontend labels Jun 20, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jun 20, 2025

I think we need a pure frontend "render plugin" mechanism

  1. Register "fronend render plugin"
  2. Plugin read page information (for example: file name)
  3. If the plugin is able to render it, read the "raw" content, then replace the "fileview" element.

I don't think we should hard-code too many file types in backend.

@kerwin612 kerwin612 force-pushed the feat/support-preview-3d-file branch from eba2b22 to 057ee0e Compare June 21, 2025 06:16
@github-actions github-actions bot removed the modifies/go Pull requests that update Go code label Jun 21, 2025
@kerwin612 kerwin612 requested review from delvh, lunny and wxiaoguang June 21, 2025 06:17
@kerwin612 kerwin612 force-pushed the feat/support-preview-3d-file branch from 057ee0e to 448effb Compare June 21, 2025 06:22
@@ -39,6 +39,7 @@
"minimatch": "10.0.2",
"monaco-editor": "0.52.2",
"monaco-editor-webpack-plugin": "7.1.0",
"online-3d-viewer": "0.16.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC it bloats the binary about 1MB

Can we introduce an config option?

For example:

Copy link
Member Author

Choose a reason for hiding this comment

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

From a user's perspective, I personally feel that direct integration is better than dynamic loading.
Because building and installation are one-time processes.
However, if we switch to dynamic loading, each time it might require dynamically loading 1MB of JavaScript.
Especially in the current Chinese network environment, sometimes even some external CDNs cannot be accessed, which would directly make the preview unavailable.

So I personally vote for integration.
Of course, the final decision is up to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

However, if we switch to dynamic loading, each time it might require dynamically loading 1MB of JavaScript.

Not "each", only once, there is browser cahce.

Especially in the current Chinese network environment, sometimes even some external CDNs cannot be accessed, which would directly make the preview unavailable.

That's why a config option to let users choose, or deploy one locally.


If we build the renders into Gitea's binary, then it bloats the binary soon when we introduce more in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fully understand your original intention, but I think this still stems from the perspective of operators. From a user's point of view, such an option shouldn't exist (or there's simply no need for it at all) – the default provided to users should inherently be the optimal solution.

Of course, I recognize that Gitea, as an open-source platform, does have many "operator" users. Your original intention might be to allow them to choose freely, but personally, I wonder if such customization is getting too caught up in minor details?

Alright, I've shared my thoughts. It's up to you all. If adjustments are needed, I'll cooperate with the changes.

Copy link
Contributor

@wxiaoguang wxiaoguang Jun 21, 2025

Choose a reason for hiding this comment

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

Share some of my thoughts:

There are different requirements for various kinds of files to render.

  • Some are widely-used, for example: CSV, PDF, etc
  • Some are only used by some of the users: asciidoc, asciicast, console, 3d models, etc. The percentage varies.

So the question is how to make Gitea have a stable and flexible design to satisfy more renders in the future. Then we have some choices:

  1. Only make widely-used renders builtin, keep the release binary as small as possible.
  2. Make all renders builtin, then we should have some estimation about the side effects, and how large the binary would be in the future.

I haven't got a clear picture of this feature at the moment. What do other maintainers think about?

Copy link
Contributor

Choose a reason for hiding this comment

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

No

Copy link
Member

Choose a reason for hiding this comment

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

image

I think the memory hog is more the git command.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the memory hog is more the git command.

I don't understand what's the point or whether it is related to the topic.

Copy link
Contributor

@TheFox0x7 TheFox0x7 Jun 23, 2025

Choose a reason for hiding this comment

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

That's a separate issue though and there's not much that can be done to limit it. Also it's (IMO) a very large issue for limited memory scenarios which is entirely of topic here.

I can't say I know a ton about this, but here point is that if you bloat the binary it had to be loaded and run each time hook runs which is a waste of resources - hope I got that right.
Honestly hook doesn't even have to have inits(not too sure about it though?) - it just needs to know where gitea is to do RPC.


Sorry for derailing the scope.

Copy link
Contributor

@wxiaoguang wxiaoguang Jun 23, 2025

Choose a reason for hiding this comment

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

Honestly hook doesn't even have to have inits(not too sure about it though?)

In history, the "gitea hook" sub commands always do various init calls (including load assets), for example: var re = regexp.MustCompile, init() { ... }, etc

When I refactor existing code, usually I also rewrite these code to something like sync.OnceValue and void unnecessary init.

About the binary size affect, it's more complicated and it depends on some OS behaviors like virtual memory/mmap management, usually the binary content should be cached in OS's shared-memory area when it runs, but it's difficult to evaluate all cases (especially when the memory is limited in a container), I am not expert either so it's just a guess.

So I also agree that "if increasing the binary size brings enough benefits, let's do it", and I think "It's fine to make this render builtin".

@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Jun 21, 2025
@lunny lunny added this to the 1.25.0 milestone Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/dependencies modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants