EllanJiang/GameFramework · error · GameFrameworkException
Main task is invalid.
Error message
Main task is invalid.
What it means
LoadDependencyAsset is a private helper that enqueues a dependency asset into a main LoadResourceTaskBase. If mainTask is null there is no valid task to attach the dependency to, indicating an internal state bug in the task-loading flow, so the framework throws this GameFrameworkException. Normal user code should never see it; it signals a framework-level invariant violation.
Solutions
- Inspect custom subclasses/patches of ResourceManager or ResourceLoader that could pass a null task into LoadDependencyAsset.
- Update GameFramework to a consistent version so LoadAsset/LoadScene always construct a valid task before processing dependencies.
- Check that asset/scene load calls are made after the resource component is initialized so tasks are created properly.
- Capture the call stack and file a bug/reproduce with a minimal LoadAsset call if it occurs on unmodified framework code.
Example fix
// before (custom derived loader)
LoadDependencyAsset(depName, priority, null, userData); // throws
// after
var mainTask = CreateLoadTask(assetName, priority, userData);
if (mainTask != null)
LoadDependencyAsset(depName, priority, mainTask, userData); Defensive patterns
Strategy: try-catch
Validate before calling
// C# (only for custom task plumbing)
if (mainTask == null)
throw new InvalidOperationException("LoadDependencyAsset requires a non-null main task."); Type guard
bool HasTask(LoadResourceTaskBase t) => t != null;
Try / catch
// C#
try { LoadAsset(assetName, priority, userData); }
catch (GameFrameworkException ex) when (ex.Message == "Main task is invalid.")
{ log.Fatal("ResourceManager task state corrupted", ex); } Prevention
- Do not modify or bypass ResourceManager's internal task creation flow.
- Keep GameFramework assemblies at one consistent version.
- Initialize the ResourceComponent before issuing any asset/scene loads.
- If extending the loader, always construct a valid task before adding dependencies.
When it happens
Trigger: An internal call path in which LoadDependencyAsset is invoked with a null mainTask — corrupted task management state, recursive dependency handling passing null, or modifications/hooks in LoadAsset/LoadScene task creation returning null.
Common situations: Custom patches to ResourceManager task flow; calling internal load helpers incorrectly from derived/custom resource components; framework version mismatch after partial upgrades of GameFramework assemblies.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Task is invalid.
- Results is invalid.
- Resource helper is invalid.
- Read-only path is invalid.
- Read-write path is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/1fa76783849c9f1b.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Resource/ResourceManager.ResourceLoader.cs:810
public TaskInfo[] GetAllLoadAssetInfos()
{
return m_TaskPool.GetAllTaskInfos();
}
/// <summary>
/// 获取所有加载资源任务的信息。
/// </summary>
/// <param name="results">所有加载资源任务的信息。</param>
public void GetAllLoadAssetInfos(List<TaskInfo> results)
{
m_TaskPool.GetAllTaskInfos(results);
}
private bool LoadDependencyAsset(string assetName, int priority, LoadResourceTaskBase mainTask, object userData)
{
if (mainTask == null)
{
throw new GameFrameworkException("Main task is invalid.");
}
ResourceInfo resourceInfo = null;
string[] dependencyAssetNames = null;
if (!CheckAsset(assetName, out resourceInfo, out dependencyAssetNames))
{
return false;
}
if (resourceInfo.IsLoadFromBinary)
{
return false;
}
LoadDependencyAssetTask dependencyTask = LoadDependencyAssetTask.Create(assetName, priority, resourceInfo, dependencyAssetNames, mainTask, userData);
foreach (string dependencyAssetName in dependencyAssetNames)
{
if (!LoadDependencyAsset(dependencyAssetName, priority, dependencyTask, userData))View on GitHub (pinned to d0c010b051)