Skip to content

fix: resolve the SDK version on every install layout - #411

Closed
xianshijing-lk wants to merge 4 commits into
mainfrom
fix/sdk-version-resolution
Closed

xianshijing-lk wants to merge 4 commits into
mainfrom
fix/sdk-version-resolution

Conversation

@xianshijing-lk

@xianshijing-lk xianshijing-lk commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Background

Unity sessions sometimes report their SDK version as "unknown" or blank, which makes Unity hard to assess per release. There were two gaps in how the version gets embedded and read:

  1. SDK vendored into Assets/. PackageVersionEmbedder looked the package up with PackageInfo.FindForAssetPath("Packages/io.livekit.livekit-sdk"). Package Manager exposes every source under that path, including registry, git URL, local file: path and embedded packages. A copy dropped straight into Assets/ has no package context, though, so the lookup returned null. The embedder then exited with a Debug.Log, and those projects reported "unknown" in the Editor and in player builds.
  2. First Editor session after the version file is created. Embed() writes Assets/Resources/LiveKitSdkVersionInfo.txt during the same domain reload in which FfiClient initializes, but Unity defers the import it requests until after the reload. In the Editor, Resources.Load goes through the AssetDatabase and couldn't see the new file yet, so that session reported "unknown". This affects a fresh clone, or any project where the file was deleted (Assets/Resources is often git-ignored). Player builds are not affected, since they read the asset packed into the build.

Not covered by this PR: apps built with SDK versions before v1.3.4 (#196) never send this value, and no Editor-side change can fix builds that already shipped.

Changes

Editor/PackageVersionEmbedder.cs

  • Resolve with PackageInfo.FindForAssembly(...), then fall back to reading the package.json next to the source for copies vendored into Assets/
  • Log a warning when the version can't be resolved, stating that sessions will report "unknown"
  • Skip the write and re-import when the file already holds the current version

Runtime/Scripts/Internal/PackageVersion.cs

  • In the Editor, fall back to reading the file from disk when Resources.Load returns null (gap 2)
  • Treat an empty file as missing
  • Warn once when no version is found

Testing

On Unity 2022.3.62f1:

  • Git-URL install (Meet sample, pointed at main with the old lookup): Packages/<name> resolved and 2.1.1 was written. This confirmed that only vendored installs were affected by gap 1.
  • Delete-and-launch on Samples~/Basic (local-path install): before the change, the first launch logged the "missing or empty" warning from FfiClient.OnAfterAssemblyReload. After the change it compiles cleanly, logs no warning, and resolves 2.1.1, even though the asset import still happens after the reload.
  • Not yet tested: a vendored-into-Assets/ install, or a player build from a fresh checkout.

🤖 Generated with Claude Code

PackageVersionEmbedder looked the package up by the literal path
"Packages/io.livekit.livekit-sdk" and returned quietly when that found
nothing. Only a registry install resolves there, so git-URL, local-path
and vendored installs never got a version asset written, and every
session from them reported its SDK version as "unknown".

Resolve from this assembly instead, which works regardless of where the
package lands, and fall back to reading package.json next to the source
for copies vendored into Assets/. Failure is now a warning that says what
it costs, rather than a Debug.Log.

PackageVersion also treats an empty asset as missing -- the other way a
version reached the server blank -- and warns once at runtime so a build
that shipped without one is visible.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Changeset missing

This PR changes versioned packages without a changeset for:

  • io.livekit.livekit-sdk

Create a changeset for the missing packages (prefilled with patch; edit the bump levels as needed), or run verwalter changeset --level <patch|minor|major> on the branch.

If this change needs no release, add the internal label.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

MaxHeimbrock and others added 2 commits December 1, 2026 10:44
PackageVersionEmbedder writes LiveKitSdkVersionInfo.txt during the same
domain reload in which FfiClient initializes, but the AssetDatabase
import it requests is deferred until the reload ends. Resources.Load
therefore returned null and the first Editor session after the file was
created reported its SDK version as "unknown". Fall back to the file on
disk in the Editor; player builds still read the packed Resources asset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

Comment on lines +25 to +28
if (string.IsNullOrEmpty(version) && System.IO.File.Exists(editorPath))
{
version = System.IO.File.ReadAllText(editorPath).Trim();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Unreadable version file blocks editor initialization

During an editor reload without a usable version asset, Get throws if the on-disk version file exists but is unreadable. InitializeSdk then skips native initialization instead of starting with unknown.

Learn more

Unity calls OnAfterAssemblyReload to initialize LiveKit after reloading its managed code. InitializeSdk fetches version metadata before registering the native callback. A file existence check does not guarantee read access. An exception from the fallback therefore aborts initialization instead of reaching the unknown-version fallback.

Example: Open a project with a fresh Unity asset cache and a generated version file copied from another account without read permission. The file can be visible in the directory even though the editor cannot import or read it. LiveKit skips native initialization instead of initializing with unknown.

Recommended fix: Catch I/O and access errors around the editor-only file read, then let the existing warning and unknown fallback run.

Suggested change
if (string.IsNullOrEmpty(version) && System.IO.File.Exists(editorPath))
{
version = System.IO.File.ReadAllText(editorPath).Trim();
}
if (string.IsNullOrEmpty(version) && System.IO.File.Exists(editorPath))
{
try
{
version = System.IO.File.ReadAllText(editorPath).Trim();
}
catch (System.Exception ex) when (ex is System.IO.IOException || ex is System.UnauthorizedAccessException)
{
// Version metadata is optional. Use the normal unknown-version fallback.
}
}

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

The old comment said git-URL and local-path installs failed the
"Packages/<name>" lookup. They do not: Package Manager exposes every
source under that virtual path. Only a copy vendored into Assets/ was
missed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxHeimbrock

Copy link
Copy Markdown
Contributor

After looking into this a bit more, I think with Verwalter there is a simpler and more robust way to do it: #412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants