Intermittent Cook Error: Content is missing from cook.

I’m getting an intermittent cook error:

Error: Content is missing from cook. Source package referenced an object in target package but the object was stripped out of the target package when saved.
	Source package: /Game/Maps/MTN/MTN_MAP/_Generated_/9A9RK32ZG0RDWX4I3G707WZXR
	Target package: /Game/Scenarios/SpawningGrounds/SpawningGrounds_Base_BP
	Referenced object: /Game/Scenarios/SpawningGrounds/SpawningGrounds_Base_BP.SpawningGrounds_Base_BP_C:ActivationSphere_GEN_VARIABLE

What causes this and how can I prevent this and why is it intermittent?

The change that incited this was a change to the SpawningGrounds_Base_BP that removed the ActivationSphere, but I’m not sure why the Actor on the map is not properly updating when it’s base asset changes, nor why this is intermittently happening.

Hello Jerek,

Could you try navigating to the location of the “Referenced Object”, right-click it, select “Validate Assets and Dependencies”, then try cooking again?

If not you could try marking the variable with the error as editor-only, compile, deselect editor-only and compile again, and see if that fixes it.

Let me know if that helps!

Thanks,

Kyle B.

Hello, though Kyle and Joan provided some (pointers for) workarounds I understand fixing up specific occurrences of the cook error isn’t a problem: resaving the OFPA actor expectedly solves the issue.

I’m refreshing my knowledge on how loading of map placed actors should clean up deleted components from the blueprint, to then better estimate what could be going wrong there. Just giving you a headsup that I’m investigating it with the intention of either:

  • Understand what situations can cause the cook error
  • Understanding why it’s intermittent, though this may be the harder question to answer
  • Hopefully some way to either catch it earlier, fix-up automatically during cook or have the error not be intermittent

When I hear intermittent load or cook errors surrounding blueprints I like to double check whether the problem BP has any cyclical dependencies. So SpawningGrounds_Base_BP in this case. The method for checking those that I trust the most is putting a breakpoint in the actor class’s native constructor, triggering a load and inspecting LoadPackageInternal() in the callstack. I describe the approach in my data loss tutorial here in the section Recognizing cyclical dependencies.

Can you perform those steps (from the article) on SpawningGrounds_Base_BP and see if loading that blueprint triggers any loading of a child blueprint?

We do support cyclical dependencies between blueprints, though historically some bugs are tied to that so it would be good to see whether that’s the case here. I’ll await your findings, but will in parallel refresh my knowledge on how deleted components should be handled. That should bring us closer to what’s going wrong on those failed cooks.

Hey Kyle,

It’s an intermittent issue, so I’m unable to locally repro it reliably.

Usually resaving it will resolve it though.

I’m trying to prevent this kind of thing from happening at all or to have it happen consistently.

An error that sometimes happens and sometimes doesn’t until the asset is touched again is one of the most disruptive issues for our CIS error reporting.

Thanks,

Jerek

I’m getting these like 4 times a day, all of which require digging into figuring out what needs to be resaved.

Any additional information?

Hi Jerek,

It looks like the issue comes from the external actor mentioned in your error message. That actor is still pointing to the ActivationSphere component you deleted previously. If it’s only this single actor, I’d recommend simply replacing it with a new one and copying over its properties. If it’s a small actor, you can do this manually via copy/paste. If it’s a more complex actor, you could automate it with a C++ or Python script that uses the Unreal reflection system to copy all the properties into a new instance.

Another possible solution would be to inspect the internal variables of the instanced actor via the reflection system, remove the stale reference manually, and then save the actor again.

After applying either solution, I’d suggest running a full clean cook (with iterative cooking disabled) to confirm the error has disappeared.

If you need to identify which actor is causing the issue, you can enable Package Short Name in the Outliner (right-click the visibility button) to show External Actor IDs.

Let us know if you’d like help implementing one of these scripts.

Best,

Joan

What’s the component type of ActivationSphere? There is a known issue with Niagara component, so it would be good to know whether ActivationSphere or any parent in the component hierarchy is a Niagara component.

I’ll check this out later today.

I have found that all cases of this have been actors placed with a 5.5 editor, then the changes made with a 5.6 editor to the base asset.

I have preempted many of the errors by doing a massive resave on all the actors in the maps.

I did get a few more from actors placed in LevelInstances and am doing a pass to resave those also

They are not cyclical dependencies.

ActivationSphere was just a shape component.

I have since gotten this on actors that have been fully resaved in 5.6, so it’s not a 5.5 to 5.6 conversion issue.

The best repro I’ve got is make a uasset with components. Place that uasset on a OFPA map.

Come back through and remove a component on the uasset and there’s a chance it may intermittently start throwing these errors until the actor is reloaded and resaved.

_GEN_VARIABLE related ‘Content is missing from cook’ errors can have two origins. One is unstable component specific logic, which it sounds like isn’t in play because you’re seeing it on a stable component type (ShapeComponent).

So lets focus on the more systemic category of problem, and that is instability during cook of UInheritableComponentHandler::ValidateTemplates. This function is trying to remove redundant component templates from blueprint component construction data in order to save memory. It uses the function IsRecordNecessary to determine whether a component template needs to stick around, and when that function is unstable we get incoherence in the object graph, which the cooker detects and reports via this error.

To confirm the issue consider adding logging to that function, keyed off of the names of problematic components or blueprints. I personally used UE::JsonObjectGraph::Stringify from JsonObjectGraph/Stringify.h to snapshot whole objects and clarify which transforms are unstable.

We have ourselves committed fixes recently for 5.7 which may be relevant:

46116159 (minor fix in 46117338) - fixed a crash on reparent of a blueprint, not likely to be relevant

35663732 - GC reachability warning fix, likely not relevant

33464964 - prevents the linker from recreating discarded component templates, could be relevant if you see FLinkerLoad recreating discarded components

Those are all the relevant fixes I know of in the post 5.6 time frame.