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

Blender imports not working in blender 4.1 (with or without RPC) #85446

Closed
mxaddict opened this issue Nov 27, 2023 · 9 comments · Fixed by #85519
Closed

Blender imports not working in blender 4.1 (with or without RPC) #85446

mxaddict opened this issue Nov 27, 2023 · 9 comments · Fixed by #85519

Comments

@mxaddict
Copy link
Contributor

mxaddict commented Nov 27, 2023

Godot version

4.2.rc.custom_build.eda44bfe1

System information

Linux 6.6.1-arch1-1 Vulkan API 1.3.255 - Forward+

Issue description

Importing .blend files not working when using blender version 4.1
When using blender version Blender 4.0.1 it is working, but without RPC (so it's very slow)

Steps to reproduce

Create a simple .blend file (default cube scene will do)
Enable blender import for the project
Set blender port and path in editor settings

Minimal reproduction project

N/A

@mxaddict
Copy link
Contributor Author

Tested this with blender 4.1.0 Alpha and am getting this error:

Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12)
Read prefs: "/home/mxaddict/.config/blender/4.1/config/userpref.blend"
Error: Python:   File "<string>", line 1
    import
          ^
SyntaxError: invalid syntax
Error: Cannot read file "/home/mxaddict/Godot/GearFear/bpy,": No such file or directory

Blender quit
ERROR: Error importing 'res://addons/mixamo/character.blend'.
   at: _reimport_file (editor/editor_file_system.cpp:2050)
Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12)
Read prefs: "/home/mxaddict/.config/blender/4.1/config/userpref.blend"
Error: Python:   File "<string>", line 1
    import
          ^
SyntaxError: invalid syntax
Error: Cannot read file "/home/mxaddict/Godot/GearFear/bpy,": No such file or directory

Blender quit

@mxaddict
Copy link
Contributor Author

Tested with blender 4.0.1:

Blender 4.0.1 (hash d0dd92834a08 built 2023-11-24 00:44:36)
Error: Cannot read file "/home/mxaddict/import sys": No suchfile or directory

Blender quit

@mxaddict
Copy link
Contributor Author

I'm pretty sure this error is related to the python script that is run via --python-expr arg on blender call.

@mxaddict
Copy link
Contributor Author

I did some more investigation and seems that --python-expr <expression> is not exposing the import libs from blender.

If I just put the <expression> into a tmp.py file, then run it via blender --background --python tmp.py it seems to be working.

@RedMser
Copy link
Contributor

RedMser commented Nov 28, 2023

To me the error looks more like it's not properly putting quotes around the command line, so new lines are interpreted as separate arguments.

Since this is a custom build, can you make sure the file is using LF line endings? Or try using an official build instead of a custom, to help narrowing it down a bit.

Otherwise I agree that it's likely more stable to use a temp file for the script instead of passing it as an argument.

@mxaddict
Copy link
Contributor Author

This issue was happening with the default version 4.1 stable.

I just tested with a custom build to see if it's still an issue with the latest version.

I have a feeling this is an issue that is only for newer versions of blender, I will test it out with older blender versions to confirm.

@mxaddict
Copy link
Contributor Author

Tested this with blender 4.1.0 Alpha and am getting this error:

Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12)
Read prefs: "/home/mxaddict/.config/blender/4.1/config/userpref.blend"
Error: Python:   File "<string>", line 1
    import
          ^
SyntaxError: invalid syntax
Error: Cannot read file "/home/mxaddict/Godot/GearFear/bpy,": No such file or directory

Blender quit
ERROR: Error importing 'res://addons/mixamo/character.blend'.
   at: _reimport_file (editor/editor_file_system.cpp:2050)
Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12)
Read prefs: "/home/mxaddict/.config/blender/4.1/config/userpref.blend"
Error: Python:   File "<string>", line 1
    import
          ^
SyntaxError: invalid syntax
Error: Cannot read file "/home/mxaddict/Godot/GearFear/bpy,": No such file or directory

Blender quit

Ok, so after more testing, this issue is not caused by godot, it's caused by aur package for blender-4.0-bin.

I've since mitigated this issue on the blender side.

Note: This issue does not happen with regular blender installs so should not be of concern to godot.

BUT: The RPC is not responding properly to the requests to 127.0.0.1 on port 6011, still investigating why that is.

@mxaddict
Copy link
Contributor Author

Seems that the while loop that checks for blender RPC service is running before the service can actually start.

ERROR: Unexpected status during RPC connection: 4
   at: do_import_rpc (modules/gltf/editor/editor_import_blend_runner.cpp:230)
Failed to connect to Blender via RPC, switching to direct imports of .blend files. Check your proxy and firewall settings, then RPC can be re-enabled by changing the editor setting `filesystem/import/blender/rpc_port` to 6011.
Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12)
Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12)
Read prefs: "/home/mxaddict/.config/blender/4.1/config/userpref.blend"
Read prefs: "/home/mxaddict/.config/blender/4.1/config/userpref.blend"
Read blend: "/home/mxaddict/Godot/TempProject/YBot.blend"
17:47:35 | INFO: Draco mesh compression is available, use library at /usr/share/blender/4.1/python/lib/python3.10/site-packages/libextern_draco.so

If you look at the logs above, you'll see that the ERROR: Unexpected status during RPC connection: 4 is run before the Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12) header is output.

And immediately after that line you have another Blender 4.1.0 Alpha (hash ce5305451ce5 built 2023-11-27 01:36:12) which is from the manual import (triggered because of RPC not quote unquote working.

@mxaddict
Copy link
Contributor Author

I've managed to get this working on a local build and created a PR #85519, it's kinda hacky but it works 🤫

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants