Repository navigation
fix: resolve the SDK version on every install layout - #411
xianshijing-lk wants to merge 4 commits into
Conversation
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>
Changeset missingThis PR changes versioned packages without a changeset for:
Create a changeset for the missing packages (prefilled with If this change needs no release, add the |
There was a problem hiding this comment.
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)
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>
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| if (string.IsNullOrEmpty(version) && System.IO.File.Exists(editorPath)) | ||
| { | ||
| version = System.IO.File.ReadAllText(editorPath).Trim(); | ||
| } |
There was a problem hiding this comment.
🔴 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.
| 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. | |
| } | |
| } |
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>
|
After looking into this a bit more, I think with Verwalter there is a simpler and more robust way to do it: #412 |
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:Assets/.PackageVersionEmbedderlooked the package up withPackageInfo.FindForAssetPath("Packages/io.livekit.livekit-sdk"). Package Manager exposes every source under that path, including registry, git URL, localfile:path and embedded packages. A copy dropped straight intoAssets/has no package context, though, so the lookup returned null. The embedder then exited with aDebug.Log, and those projects reported"unknown"in the Editor and in player builds.Embed()writesAssets/Resources/LiveKitSdkVersionInfo.txtduring the same domain reload in whichFfiClientinitializes, but Unity defers the import it requests until after the reload. In the Editor,Resources.Loadgoes 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/Resourcesis 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.csPackageInfo.FindForAssembly(...), then fall back to reading thepackage.jsonnext to the source for copies vendored intoAssets/"unknown"Runtime/Scripts/Internal/PackageVersion.csResources.Loadreturns null (gap 2)Testing
On Unity 2022.3.62f1:
mainwith the old lookup):Packages/<name>resolved and2.1.1was written. This confirmed that only vendored installs were affected by gap 1.Samples~/Basic(local-path install): before the change, the first launch logged the "missing or empty" warning fromFfiClient.OnAfterAssemblyReload. After the change it compiles cleanly, logs no warning, and resolves2.1.1, even though the asset import still happens after the reload.Assets/install, or a player build from a fresh checkout.🤖 Generated with Claude Code