Fix #114582: Replace unknown node types with an 'undefined' node #114783

Merged
Lukas Tönne merged 5 commits from LukasTonne/blender:replace-unknown-node-types into blender-v3.3-release 2023-11-13 16:20:51 +01:00
Member

When loading an unknown node type from a newer Blender version, the node
storage data cannot be properly loaded. Re-saving the file will then
crash if saving with the same node type idname, since new Blender
versions cannot find the expected storage data.

Loading in older versions should replace unknown node types with a dummy
"Undefined" node that will get loaded as NodeTypeUndefined in newer
versions as well. Custom node types are exempted from this since they
store all data as generic ID properties and can always be fully
serialized.

When loading an unknown node type from a newer Blender version, the node storage data cannot be properly loaded. Re-saving the file will then crash if saving with the same node type idname, since new Blender versions cannot find the expected storage data. Loading in older versions should replace unknown node types with a dummy "Undefined" node that will get loaded as `NodeTypeUndefined` in newer versions as well. Custom node types are exempted from this since they store all data as generic ID properties and can always be fully serialized.
Lukas Tönne added 1 commit 2023-11-13 12:01:04 +01:00
3f668072ee Fix #114582: Replace unknown node types with an 'undefined' node.
When loading an unknown node type from a newer Blender version, the node
storage data cannot be properly loaded. Re-saving the file will then
crash if saving with the same node type idname, since new Blender
versions cannot find the expected storage data.

Loading in older versions should replace unknown node types with a dummy
"Undefined" node that will get loaded as `NodeTypeUndefined` in newer
versions as well. Custom node types are exempted from this since they
store all data as generic ID properties and can always be fully
serialized.
Author
Member

This should be ported to 3.6 LTS and 4.0.

This should be ported to 3.6 LTS and 4.0.
Lukas Tönne requested review from Brecht Van Lommel 2023-11-13 12:02:24 +01:00
Lukas Tönne added this to the Nodes & Physics project 2023-11-13 12:02:29 +01:00
Brecht Van Lommel requested changes 2023-11-13 13:08:25 +01:00
@ -675,0 +680,4 @@
}
/* Check known built-in types. */
NODE_TYPES_BEGIN (ntype) {

This has bad time complexity, can't we use something like nodeTypeFind?

This has bad time complexity, can't we use something like `nodeTypeFind`?
Author
Member

We don't have a global registry map by static node type, since static ids are sometimes shared between different node types. But i've added a static set to check for known types, which is only built once.

We don't have a global registry map by static node type, since static ids are sometimes shared between different node types. But i've added a static set to check for known types, which is only built once.
LukasTonne marked this conversation as resolved
Lukas Tönne added 1 commit 2023-11-13 13:44:54 +01:00
Lukas Tönne added 1 commit 2023-11-13 13:49:02 +01:00
Iliya Katushenock reviewed 2023-11-13 13:50:46 +01:00
@ -675,0 +675,4 @@
/* Build a static set of built-in node types to check for known types. */
static blender::Set<int> get_known_node_types_set()
{
blender::Set<int> result;

Right now that is not static.

Right now that is not static.
static const Set<int> types = []() {
  Set<int> types;
  for () { add(); }
  return types;
}();
```Cpp static const Set<int> types = []() { Set<int> types; for () { add(); } return types; }(); ```

It doesn't need to be because it's static in can_read_node_type, but the comment is a bit confusing.

It doesn't need to be because it's static in `can_read_node_type`, but the comment is a bit confusing.
Author
Member

Removed "static" from the comment.

Removed "static" from the comment.

Oh, hm, now that is just linead building of set + ((O(1) + 0(N)) / 2) for lookup.

Oh, hm, now that is just linead building of set + ((O(1) + 0(N)) / 2) for lookup.
mod_moder marked this conversation as resolved
Lukas Tönne added 1 commit 2023-11-13 13:58:42 +01:00
Brecht Van Lommel approved these changes 2023-11-13 14:15:40 +01:00
@ -675,0 +692,4 @@
/* Check known built-in types. */
static blender::Set<int> known_types = get_known_node_types_set();
if (known_types.contains(type)) {

Can be simpler: return known_types.contains(types);

Can be simpler: `return known_types.contains(types);`
LukasTonne marked this conversation as resolved

I would not put this in 4.0.0 by the way, since there is some risk to this. Could be put on in main and on the list for 4.0.1 if we find no problems.

I would not put this in 4.0.0 by the way, since there is some risk to this. Could be put on in main and on the list for 4.0.1 if we find no problems.
Lukas Tönne added 1 commit 2023-11-13 15:45:30 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
a985d75f8e
Cleanup: simpler return expression.
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne merged commit 5715c9a323 into blender-v3.3-release 2023-11-13 16:20:51 +01:00
Lukas Tönne deleted branch replace-unknown-node-types 2023-11-13 16:20:56 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#114783
No description provided.