EllanJiang/GameFramework · error · GameFrameworkException

There is already a resource pack

Error message

There is already a resource pack '{0}' being applied.

What it means

ApplyResources throws this (with the pack path interpolated) when another resource pack is currently being applied — m_ApplyingResourcePackStream is non-null. Only one resource pack can be applied at a time because the manager holds an open FileStream for the pack being applied.

Solutions

  1. Wait for the ResourceApplyStart/ResourceApplySuccess/ResourceApplyFailure callbacks before applying another pack
  2. Queue pack paths and apply them sequentially from the completion callback
  3. Guard the call with a UI/dispatch lock so duplicate invocations are ignored

Example fix

// before
foreach (var pack in packs) resourceManager.ApplyResources(pack); // concurrent applies
// after
void OnApplyComplete(...) { if (queue.Count > 0) resourceManager.ApplyResources(queue.Dequeue()); }
resourceManager.ApplyResources(queue.Dequeue());
Defensive patterns

Strategy: try-catch

Validate before calling

// guard in caller code
if (m_ApplyingPack) return; // already applying

Try / catch

try { resourceManager.ApplyResources(packPath); } catch (GameFrameworkException ex) { Log.Warn("Pack application already in progress, queued: " + ex.Message); m_PendingPacks.Enqueue(packPath); }

Prevention

When it happens

Trigger: Calling ApplyResources a second time while the first pack application is still in progress and its completion callback has not fired; re-entering ApplyResources from an event triggered during application.

Common situations: UI double-click or repeated retry logic firing ApplyResources twice; applying multiple packs in a loop without waiting for per-pack completion; an earlier application that stalled without a failure/success callback.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/00f2fb0ab0617ef1. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Resource/ResourceManager.ResourceUpdater.cs:325

                {
                    GenerateReadWriteVersionList();
                }
            }

            /// <summary>
            /// 应用指定资源包的资源。
            /// </summary>
            /// <param name="resourcePackPath">要应用的资源包路径。</param>
            public void ApplyResources(string resourcePackPath)
            {
                if (!m_CheckResourcesComplete)
                {
                    throw new GameFrameworkException("You must check resources complete first.");
                }

                if (m_ApplyingResourcePackStream != null)
                {
                    throw new GameFrameworkException(Utility.Text.Format("There is already a resource pack '{0}' being applied.", m_ApplyingResourcePackPath));
                }

                if (m_UpdatingResourceGroup != null)
                {
                    throw new GameFrameworkException(Utility.Text.Format("There is already a resource group '{0}' being updated.", m_UpdatingResourceGroup.Name));
                }

                if (m_UpdateWaitingInfoWhilePlaying.Count > 0)
                {
                    throw new GameFrameworkException("There are already some resources being updated while playing.");
                }

                try
                {
                    long length = 0L;
                    ResourcePackVersionList versionList = default(ResourcePackVersionList);
                    using (FileStream fileStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read))
                    {

View on GitHub (pinned to d0c010b051)