

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 对 Proton 的兼容性进行故障排除
<a name="troubleshoot-compatibility-wp-proton"></a>

 在本步骤中，您将在自己的计算机上设置 Proton，这样您就可以解决您的 Amazon GameLift Streams 应用程序和 Proton 之间的兼容性问题。在没有 Amazon GameLift Streams 服务器的模拟环境中运行应用程序可以帮助您识别应用程序和运行时环境的特定问题。

## 先决条件
<a name="troubleshoot-compatibility-wp-proton-prereq"></a>
+  安装了 GPU 驱动程序的 Ubuntu 22.04 LTS。有关说明，请参阅[设置本地机器](troubleshoot-compatibility-setup-local.md)或[设置远程机器](troubleshoot-compatibility-setup-remote.md)。

## 安装 Proton
<a name="troubleshoot-compatibility-wp-proton-install"></a>

[要在 Ubuntu 22.04 LTS 计算机上安装 Proton，请使用以下脚本从 Proton 存储库中克隆、构建和配置要测试的 Proton 版本。 GitHub ](https://github.com/ValveSoftware/Proton/)

1. 将以下代码复制并粘贴到您的 Ubuntu 22.04 LTS 计算机`proton-setup.sh`上名为的文件中。

   ```
   #!/bin/bash
   # This is a script to build Proton. The default build is a tag from the 
   # experimental_9.0 branch of Proton, but can be changed as a parameter to this script.
   #
   # Usage: ./proton-setup.sh [optional proton_branch_name {default: experimental-9.0-20241121b}]
   set -e
   
   sudo apt install -y podman make git
   
   # clone proton from github, recurse submodules
   # if no proton git link is supplied, use a default tag from the experimental_8.0 branch
   PROTON_BRANCH=${1:-"experimental-9.0-20241121b"}
   PROTON_BUILD_DIR=protonBuild
   PROTON_DIR=$(pwd)/proton
   if git clone https://github.com/ValveSoftware/Proton.git --recurse-submodules --branch $PROTON_BRANCH proton;
   then
   	echo "Successfully cloned Proton and its submodules."
   else
   	echo "Warning: a proton directory/repository already exists. It is recommended to delete this folder and re-run this script unless it is a valid repository with initialized submodules."
   fi
   
   if [ -d $PROTON_BUILD_DIR ];
   then
   	echo "Error: protonBuild directory already exists. Delete this folder first to create a fresh build of Proton before re-running this script."
   	exit 1
   fi
   mkdir $PROTON_BUILD_DIR
   cd $PROTON_BUILD_DIR
   $PROTON_DIR/configure.sh --enable-ccache --container-engine=podman
   
   # build proton
   echo "Building Proton"
   make
   echo "Done building Proton!"
   
   # prepare proton for execution
   cd dist
   mkdir compatdata
   if [ -e ./dist ]; then
     PROTON_FILES=dist
   elif [ -e ./files ]; then
     PROTON_FILES=files
   fi
   cp version $PROTON_FILES/
   echo "Finished installing proton. Proton binary location: $(pwd)/proton"
   echo "STEAM_COMPAT_DATA_PATH: $(pwd)/compatdata"
   echo "STEAM_COMPAT_CLIENT_INSTALL_PATH: anything"
   ```

1. 在此步骤中，您将运行 Proton 安装脚本来克隆和安装 Proton 和其他依赖项。该脚本接受要安装的 Proton 版本的标签或分支名称作为参数。要模拟 Amazon GameLift Streams 提供的其中一个 Proton 定制版本，请使用以下该版本的说明。
**注意**  
 预计克隆 GitHub 需要一些时间。有许多子模块可供下载，总数为几千兆字节。

    在您的终端中，运行`proton-setup.sh`脚本并指定 Proton 版本分支：
   +  **内置 Proton 版本** 
     + [对于 Proton 9.0-2 (`PROTON-20250516`)，请使用 experimental-9.0-20241121b。](https://github.com/ValveSoftware/Proton/tree/experimental-9.0-20241121b)

       ```
       proton-setup.sh experimental-9.0-20241121b
       ```
     + [对于 Proton 8.0-5 (`PROTON-20241007`)，请使用 experimental-8.0-20240205。](https://github.com/ValveSoftware/Proton/tree/experimental-8.0-20240205)

       ```
       proton-setup.sh experimental-8.0-20240205
       ```

       通常，不需要额外的源代码。但是，如果你在使用Electra Media Player（虚幻引擎插件）时遇到问题，我们建议你使用 [https://github.com/ValveSoftware/win](https://github.com/ValveSoftware/wine/pull/257) e/pull/257中的修复程序。
**注意**  
 对于 Proton 8.0-2c ()`PROTON-20230704`，Amazon GameLift Streams 使用专有版本，该版本无法在本地构建。
   +  **推荐的定制 Proton 版本** 

      对于自定义 Proton 版本，我们建议使用 Proton experimental\$18.0 分支。

     ```
     proton-setup.sh experimental_8.0
     ```
   +  **其他定制 Proton 版本** 

      [对于其他 Proton 版本，请使用 Proton 版本中列出的确切分支或标签名称。](https://github.com/ValveSoftware/Proton/releases)

     ```
     proton-setup.sh branch-or-tag-name
     ```

    如果安装成功，则终端中的输出应类似于以下内容：

   ```
   ...
   Done building Proton!
   Finished preparing proton. Proton binary location: /home/test/protonBuild/dist/proton
   STEAM_COMPAT_DATA_PATH: /home/test/protonBuild/dist/compatdata
   STEAM_COMPAT_CLIENT_INSTALL_PATH: anything
   ```

    请记下输出中的以下变量，因为在下一步中将需要它们来运行 Proton：
   + Proton 二进制位置
   + `STEAM_COMPAT_DATA_PATH`
   + `STEAM_COMPAT_CLIENT_INSTALL_PATH`

## 在 Proton 上运行你的应用程序
<a name="troubleshoot-compatibility-wp-proton-run"></a>

 以下步骤假设应用程序可执行文件位于中`path/myapplication/bin/application.exe`。将其替换为应用程序的路径和文件名。
+ 在终端中，导航到应用程序可执行文件所在的文件夹。

  ```
  cd path/myapplication/bin/application.exe
  ```
+ 在 Proton 上运行您的应用程序。使用上一步中获得的 Proton 二进制位置和环境变量。

  ```
  STEAM_COMPAT_DATA_PATH=/home/test/protonBuild/dist/compatdata STEAM_COMPAT_CLIENT_INSTALL_PATH=anything /home/test/protonBuild/dist/proton run application.exe
  ```

 应用程序现在应该尝试启动。如果应用程序在本地启动，但不能在 Amazon GameLift Streams 上启动，则可能是由于调用 Amazon GameLift Streams 时出现配置问题所致 APIs。验证 API 调用参数是否正确。否则，请继续执行下一步进行调试。

## 通过日志文件调试应用程序
<a name="troubleshoot-compatibility-wp-proton-debug-logs"></a>

 如果您的应用程序在本地 Proton 环境中运行时遇到问题，请查看输出日志。该日志包含您的应用程序和运行时环境的输出。跟踪您的应用程序未能在应用程序端发现问题的地方。

 要将日志输出转储到文本文件中，例如`proton.log`，请使用以下命令：

```
STEAM_COMPAT_DATA_PATH=/home/test/protonBuild/dist/compatdata STEAM_COMPAT_CLIENT_INSTALL_PATH=anything /home/test/protonBuild/dist/proton run application.exe &>proton.log
```

 Proton 还会指出问题是否由于 Wine 插件、未实现的函数、缺少 dll 等。有关更多信息，请参阅 [Wine HQ 的《调试 Win](https://wiki.winehq.org/Wine_Developers_Guide/Debugging_Wine) e 指南》。如果您在日志中发现应用程序端无法修复的 Proton 或 Wine 错误，请联系您的 AWS 客户经理或在 re [AWS : Post 中发布问题以获取进一步调试](https://repost.aws/tags/TAOU7EpUOuTQSSWmIHCfb2fQ/amazon-gamelift-streams)的帮助。