X Tutup
Skip to content

Fix AnimationMixer error spam by respecting cache validity on invalid root_node#113140

Merged
akien-mga merged 1 commit intogodotengine:masterfrom
LanzaSchneider:fix-animation-mixer-invalid-cache-spam
Nov 26, 2025
Merged

Fix AnimationMixer error spam by respecting cache validity on invalid root_node#113140
akien-mga merged 1 commit intogodotengine:masterfrom
LanzaSchneider:fix-animation-mixer-invalid-cache-spam

Conversation

@LanzaSchneider
Copy link
Contributor

@LanzaSchneider LanzaSchneider commented Nov 25, 2025

Description

When an AnimationMixer has an invalid root_node path assigned, attempting to play an animation causes the engine to spam the console with "No animation in cache" errors on every frame. This makes debugging extremely difficult and obscures real issues.

For example:

extends Node3D

@export_node_path("AnimationPlayer")
var path_to_animation_player: NodePath
@export
var animation_library: AnimationLibrary

func _ready() -> void:
	var animation_player: AnimationPlayer = get_node(path_to_animation_player)
	var library_name := 'test'
	animation_player.add_animation_library(library_name, animation_library)
	animation_player.root_node = NodePath('2025/11/25')
	animation_player.play('%s/%s' % [library_name, animation_library.get_animation_list()[0]])

it gives No animation in cache errors on every frame:
p1

Root Cause

The _update_caches() method correctly detects an invalid root_node and sets cache_valid = false. However, _blend_pre_process() was returning true, which allowed _process_animation() to continue executing the entire blending pipeline (_blend_calc_total_weight(), _blend_process(), etc.). These downstream functions then fail due to missing caches and spam errors repeatedly.

Proposed Solution

  • Changed the return value of _blend_pre_process() from true to cache_valid. This ensures that if caches are not built (due to invalid root_node or other reasons), the entire blending process is skipped immediately.
  • Enhanced the warning in _update_caches() to be more descriptive and use WARN_PRINT_ONCE, providing developers with an immediate, actionable message instead of vague downstream errors.

After these changes, it gives:
{5A4D21D3-E0AE-4CC7-B7ED-286FC398A538}

@LanzaSchneider LanzaSchneider requested a review from a team as a code owner November 25, 2025 03:23
@LanzaSchneider LanzaSchneider force-pushed the fix-animation-mixer-invalid-cache-spam branch from aa1013e to a15c8e4 Compare November 25, 2025 03:27
@fire fire moved this to Ready for review in Animation Team Issue Triage Nov 25, 2025
@AThousandShips AThousandShips added this to the 4.6 milestone Nov 25, 2025
Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

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

Considering the function's meaning, I think it is incorrect for _blend_pre_process() to return cache_valid.

Therefore, if you want to do that, simply adding the following check should suffice:

animation_mixer.cpp

void AnimationMixer::_process_animation(double p_delta, bool p_update_only) {
	_blend_init();
	if (cache_valid && _blend_pre_process(p_delta, track_count, track_map)) {
		_blend_capture(p_delta);
		_blend_calc_total_weight();
		_blend_process(p_delta, p_update_only);
		_blend_apply();
		_blend_post_process();
		emit_signal(SNAME("mixer_applied"));
	};
	clear_animation_instances();
}

@LanzaSchneider LanzaSchneider force-pushed the fix-animation-mixer-invalid-cache-spam branch from a15c8e4 to d968c3e Compare November 25, 2025 14:52
Copy link
Contributor Author

@LanzaSchneider LanzaSchneider left a comment

Choose a reason for hiding this comment

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

accepted

@TokageItLab TokageItLab moved this from Ready for review to Approved, Waiting for Production in Animation Team Issue Triage Nov 26, 2025
@akien-mga akien-mga merged commit 9c7bea6 into godotengine:master Nov 26, 2025
20 checks passed
@github-project-automation github-project-automation bot moved this from Approved, Waiting for Production to Done in Animation Team Issue Triage Nov 26, 2025
@akien-mga
Copy link
Member

Thanks!

@LanzaSchneider LanzaSchneider deleted the fix-animation-mixer-invalid-cache-spam branch November 27, 2025 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup