Quick answer: Device rotation triggers AR session pause; subscribe to ARSession.stateChanged and reinitialize after rotation completes.

If you are searching for how to fix unity ar foundation tracking lost on rotation, you are in the right place. This is a recurring issue in Unity that catches both new and experienced developers. The behavior looks like a deep engine bug, but the root cause is usually a small interaction between two systems that the documentation does not call out. Below is the full breakdown of the symptom, why it happens, a step-by-step fix you can apply today, and the diagnostic workflow to confirm everything is working.

The Symptom

Your AR app works fine in portrait, but rotating the device to landscape causes tracking to drop. Placed objects disappear or jump to incorrect positions. Tracking eventually recovers but anchors are misaligned.

This kind of symptom tends to be deterministic in the editor but harder to reproduce in shipped builds, where the conditions that trigger it depend on player behavior, hardware, or timing that you cannot fully control during development. If you have a player bug report that matches the description above, the same fix usually applies.

Root Cause

AR Foundation pauses the underlying ARKit/ARCore session during device rotation because the camera intrinsics change with orientation. When the session resumes, it re-initializes pose tracking from the new orientation - any anchors created before rotation may map to incorrect world positions.

This pattern shows up in many areas of Unity where two subsystems communicate through a shared but loosely-typed contract. The first subsystem reports success at its layer; the second subsystem silently rejects or transforms the data without an error. Because there is no exception at the boundary, the only visible evidence is the wrong output at the end of the pipeline, which is where most developers start their investigation. Tracing the bug backwards through the layers reveals the actual mismatch.

The Fix

Step 1. Subscribe to ARSession.stateChanged. When state transitions to SessionTracking, walk through your anchor list and verify each anchor's trackingState. Recreate anchors that show Limited or None.

using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;

public class AROrientationHandler : MonoBehaviour {
    [SerializeField] ARSession session;
    [SerializeField] ARAnchorManager anchorManager;
    List<Vector3> savedAnchorPositions = new();

    void OnEnable() {
        ARSession.stateChanged += OnSessionStateChanged;
    }

    void OnSessionStateChanged(ARSessionStateChangedEventArgs args) {
        if (args.state == ARSessionState.SessionTracking) {
            RestoreAnchors();
        } else if (args.state == ARSessionState.SessionInitializing) {
            SaveAnchorPositions();
        }
    }

    void SaveAnchorPositions() {
        savedAnchorPositions.Clear();
        foreach (var a in anchorManager.trackables) {
            savedAnchorPositions.Add(a.transform.position);
        }
    }

    void RestoreAnchors() {
        foreach (var pos in savedAnchorPositions) {
            anchorManager.AddAnchor(new Pose(pos, Quaternion.identity));
        }
    }
}

Step 2. Store anchor positions in world space and re-place anchors after rotation using the same world coordinates. The session re-establishes the same world origin so positions remain consistent.

// Or lock orientation
void Awake() {
    Screen.autorotateToPortrait = true;
    Screen.autorotateToLandscapeLeft = false;
    Screen.autorotateToLandscapeRight = false;
    Screen.autorotateToPortraitUpsideDown = false;
}

Step 3. Lock the device orientation in Player Settings to avoid the rotation entirely - many AR experiences are designed for portrait or landscape only.

Diagnostic workflow

Before you call the bug fixed, walk through this short checklist to confirm the fix addresses the actual cause and not a similar-looking symptom. First, reproduce the issue deterministically in a minimal scene. If you cannot get the same failure twice in a row, your fix attempts will be hard to evaluate, so spend the time to lock down a clean repro before changing any code. Second, apply only the fix - resist the urge to also clean up surrounding code. A single-variable change makes it obvious which edit resolved the symptom. Third, run the repro three or more times after the fix to confirm the issue does not return intermittently.

If the fix works in the editor but the symptom returns in a build, the most common explanation is a configuration difference. Build settings, asset import flags, and platform-specific feature toggles can change behavior between editor playthrough and shipped binary. Add platform-conditional logging around the fix code, ship a debug build with the logs enabled, and verify the relevant configuration values match expectations on the target device.

Why this happens

This bug class lives at the boundary between two Unity subsystems. The first system reports success at its layer; the second system silently rejects or transforms the data without raising an error. Because the boundary is not loud about its expectations, the symptom only appears at the end of the pipeline. The fix above addresses the configuration mismatch at the boundary - once the two systems agree on the data contract, the symptom disappears immediately.

This is also why the bug feels disproportionate to the fix. A one-line change resolves what looked like a fundamental engine problem because the engine was working correctly all along - it was just being asked to do something slightly different from what the calling code expected. Understanding the boundary contract is the durable lesson; the specific fix is the immediate payoff.

Verifying the fix

Reproduce the original symptom in isolation before applying the fix. If you cannot reliably reproduce, you cannot reliably verify - and you risk shipping a fix that addresses a different bug. Start with a minimal scene or scenario that triggers the issue every time, apply the change above, and run the same scenario at least three times to confirm the symptom is gone. Once the minimal repro is clean, retest in the full game to confirm the fix doesn't regress anything else.

For shipping games, follow a staged rollout. Push the fix to five to ten percent of players first, monitor the affected metric (crash rate, error log frequency, gameplay telemetry) for twenty-four to forty-eight hours, and expand only if the data confirms the fix without regressions. A staged rollout is cheap insurance against an interaction you did not anticipate in your test environment.

Capturing the bug from players

The hardest part of fixing this kind of issue is getting a player report that includes enough context to reproduce. Most players describe the symptom in their own words and omit the build number, scene name, hardware, or input sequence that triggered it. Without those details, you are guessing at the conditions and that guesswork is where most engineering time is wasted on production bugs.

A bug reporting SDK like Bugnet for Unity captures the build SHA, scene name, recent logs, device specs, frame rate, and a screenshot automatically whenever a player files a report. With that bundle attached, you can reproduce the bug locally instead of guessing - typically the difference between a one-day fix and a one-week investigation. The same SDK also catches unhandled errors automatically, so you get the report even when the player does not file one.

Edge cases to watch for

The same root cause can produce slightly different symptoms in adjacent systems. After fixing the case you found, spend thirty minutes searching your project for similar patterns - the same API called with different arguments, the same data flow with a different entity type, or the same lifecycle issue in a sibling module. Each match is a candidate for the same fix, or a related fix that prevents future bugs of the same class. Building this catalog of 'we've seen this before' pattern is valuable institutional knowledge that compounds with each project.

Pay extra attention to boundary conditions - the first frame, the last frame, zero or maximum values, and the transition between two states. These are where engines often have undocumented behavior, and where regression tests pay the highest dividend. A test that exercises the boundary catches the subtle regressions that look like new bugs but are really the original returning. Add one or two of these boundary tests after every bug fix; they earn their keep over the long life of the project.

When to escalate

If you have applied the fix above and the symptom persists, the bug is likely in a different layer than this article addresses. Capture a video of the symptom, the exact reproduction steps, the Unity version, and any recent changes to the project. File a report on the official issue tracker with that bundle - the maintainers are responsive when the report is complete, and a well-reproduced issue often gets a workaround posted within a few days.

Before filing, search the existing issues for keywords related to your symptom. Many bug reports are duplicates of issues that have a workaround posted in the comments but no formal fix in the engine. Reading the existing thread often resolves the issue faster than a new report, and adding a +1 with your repro to an existing issue is more useful to the maintainers than another duplicate. For paid licenses (Unity Pro, Unreal Source Access), use the support portal for faster turnaround on engine-level bugs.

Check the boundary; the bug lives between systems.