fix(manage_build): stop forcing PVRTC texture compression on Android via subtarget#1253
Conversation
…via subtarget When manage_build builds for Android, BuildPlayerOptions.subtarget was always set to StandaloneBuildSubtarget.Player (0). On Android, subtarget maps to MobileTextureSubtarget (texture compression format). Building with subtarget=0 on Unity 6000+ triggers a confirmed Unity bug (IN-102413) that forces PVRTC texture compression — ignoring the project's Player Settings (ASTC/ETC2). Worse: setting subtarget persists the value in EditorUserBuildSettings, overwriting whatever the user configured in Build Settings. Fix: only set subtarget for Standalone platforms (Windows/OSX/Linux), where it distinguishes Server vs Player builds. For all other platforms (Android, iOS, tvOS, WebGL, etc.), leave subtarget at its default so Unity respects the project's Player Settings. Fixes CoplayDev#1212
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughBuildRunner.CreateBuildOptions was modified so BuildPlayerOptions.subtarget is set only for specific desktop Standalone build targets (Windows, Windows64, OSX, Linux64) instead of unconditionally, with comments explaining platform-specific behavior and a related Unity 6000+ texture compression bug. ChangesBuild Options Subtarget Fix
Estimated code review effort: 2 (Simple) | ~10 minutes Related issues: Suggested reviewers: none identified 🐰 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Android AAB built via
manage_buildforces PVRTC texture compression, even when the project's Player Settings are set to ASTC / "Use Player Settings." The resulting AAB includes<supports-gl-texture android:name="GL_IMG_texture_compression_pvrtc"/>in its manifest, which excludes ~75% of Android devices (most Adreno/Mali phones) on Google Play. The identical project built from the Unity Editor UI does NOT add this requirement.Fixes #1212
Root Cause
Two compounding issues:
Code forcing wrong subtarget for mobile:
BuildRunner.CreateBuildOptionsalways setBuildPlayerOptions.subtarget = StandaloneBuildSubtarget.Player(value 0). On Android,subtargetis interpreted asMobileTextureSubtarget(texture compression format). Value 0 maps to PVRTC in Unity 6000+.Persistent side effect: The Unity docs state that setting
subtargetpersists the value inEditorUserBuildSettings, overwriting whatever the user had configured in Build Settings / Player Settings.This is a confirmed upstream Unity bug: IN-102413 — "Texture Compression default texture format is set to PVRTC when building via script BuildPipeline.BuildPlayer" (reproducible in 6000.0.57f1+).
Solution
Only set
subtargetfor Standalone platforms (Windows, OSX, Linux), where it distinguishes Server vs Player builds. For all other platforms (Android, iOS, tvOS, WebGL, etc.), leavesubtargetunset so Unity respects the project's Player Settings and Build Settings.Before:
subtarget = StandaloneBuildSubtarget.Player(0) was passed for ALL targets, forcing PVRTC on Android.After:
subtargetis only set for Standalone targets; other platforms use the platform default.Verification
subtarget = StandaloneBuildSubtarget.Server(1) still works — the check passes it through.subtarget = StandaloneBuildSubtarget.Player(0) still works.subtargetis now left at struct default (0), which means Unity reads the actual texture compression from Player Settings.CreateBuildOptionshandles it at the single entry point.Notes
texture_compressionparameter tomanage_buildand/or readPlayerSettings.GetMobileTextureCompressionFormatto set subtarget explicitly.Summary by CodeRabbit