Skip to content

fix(manage_build): stop forcing PVRTC texture compression on Android via subtarget#1253

Open
beast-ofcourse wants to merge 1 commit into
CoplayDev:betafrom
beast-ofcourse:fix/managebuild-android-pvrtc-texture
Open

fix(manage_build): stop forcing PVRTC texture compression on Android via subtarget#1253
beast-ofcourse wants to merge 1 commit into
CoplayDev:betafrom
beast-ofcourse:fix/managebuild-android-pvrtc-texture

Conversation

@beast-ofcourse

@beast-ofcourse beast-ofcourse commented Jul 7, 2026

Copy link
Copy Markdown

Problem

Android AAB built via manage_build forces 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:

  1. Code forcing wrong subtarget for mobile: BuildRunner.CreateBuildOptions always set BuildPlayerOptions.subtarget = StandaloneBuildSubtarget.Player (value 0). On Android, subtarget is interpreted as MobileTextureSubtarget (texture compression format). Value 0 maps to PVRTC in Unity 6000+.

  2. Persistent side effect: The Unity docs state that setting subtarget persists the value in EditorUserBuildSettings, 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 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 unset 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: subtarget is only set for Standalone targets; other platforms use the platform default.

Verification

  • Standalone Server builds: subtarget = StandaloneBuildSubtarget.Server (1) still works — the check passes it through.
  • Standalone Player builds: subtarget = StandaloneBuildSubtarget.Player (0) still works.
  • Android builds: subtarget is now left at struct default (0), which means Unity reads the actual texture compression from Player Settings.
  • No change to the batch build path's hardcoded subtarget — CreateBuildOptions handles it at the single entry point.

Notes

  • There is a separate confirmed Unity 6000 bug (IN-102413) where even the default subtarget on Android defaults to PVRTC. This fix prevents our code from actively FORCING the wrong value, which was the main issue. The Unity bug itself needs to be tracked separately.
  • For Unity 6000 users who still encounter PVRTC defaulting, a future enhancement could add an explicit texture_compression parameter to manage_build and/or read PlayerSettings.GetMobileTextureCompressionFormat to set subtarget explicitly.

Summary by CodeRabbit

  • Bug Fixes
    • Improved build settings handling for certain platforms to avoid unintended texture compression.
    • Made build behavior more reliable by only applying platform-specific build options where they’re supported.

…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
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 258aba3e-c814-4f01-a024-ce068c0d731e

📥 Commits

Reviewing files that changed from the base of the PR and between 484937c and 6598302.

📒 Files selected for processing (1)
  • MCPForUnity/Editor/Tools/Build/BuildRunner.cs

📝 Walkthrough

Walkthrough

BuildRunner.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.

Changes

Build Options Subtarget Fix

Layer / File(s) Summary
Conditional subtarget assignment
MCPForUnity/Editor/Tools/Build/BuildRunner.cs
subtarget is now only set for StandaloneWindows, StandaloneWindows64, StandaloneOSX, and StandaloneLinux64 targets, left at default otherwise, with comments explaining a Unity 6000+ bug causing unintended texture compression on other platforms.

Estimated code review effort: 2 (Simple) | ~10 minutes

Related issues: #1212 — addresses forced PVRTC texture compression on Android AAB builds caused by unconditional subtarget assignment.

Suggested reviewers: none identified

🐰
A subtarget once set for all,
now waits for desktop's call,
ASTC stays true,
PVRTC bug — adieu,
Android builds no longer fall.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the Android PVRTC fix and matches the main code change.
Description check ✅ Passed It includes the problem, root cause, solution, verification, and linked issue, so it is sufficiently complete.
Linked Issues check ✅ Passed The code change leaves subtarget unset for Android and other non-Standalone targets, matching issue #1212's required behavior.
Out of Scope Changes check ✅ Passed The PR only adjusts build option subtarget handling and related comments, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Bug]: manage_build (Android/AAB) forces PVRTC texture compression, ignoring the project's texture settings → Google Play excludes ~75% of devices

1 participant