

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

# 测试和排除与 Proton for Amazon Streams 的兼容性 GameLift
<a name="troubleshoot-compatibility-wp"></a>

 如果您的 Amazon GameLift Streams 应用程序在 Proton 运行时环境中运行，则本节可以帮助您解决应用程序与 Proton 层之间的兼容性问题。这些说明包括一组脚本，用于将 Proton 安装到您自己的计算机上，模拟 Amazon GameLift Streams 将使用的环境。通过在不使用 Amazon GameLift Streams 服务的情况下进行故障排除，您可以专注于解决应用程序和运行时环境的特定问题。

## 测试和故障排除的高级步骤
<a name="troubleshoot-compatibility-wp-high-level-steps"></a>

1.  购买一台 Ubuntu 22.04 LTS 机器。您可以使用本地计算机或 Amazon EC2 基于云的桌面。请从以下主题中进行选择以获取说明：
   + [设置本地机器](troubleshoot-compatibility-setup-local.md)
   + [设置远程机器](troubleshoot-compatibility-setup-remote.md)

1.  安装 Proton 运行时环境以测试和调试您的应用程序。有关指导，[在 Proton 上进行故障排除](troubleshoot-compatibility-wp-proton.md)请参阅。

## Proton 的已知问题
<a name="troubleshoot-compatibility-known-issues"></a>

有关最新的兼容性和疑难解答资源，请参阅 [Proton GitHub 维基](https://github.com/ValveSoftware/Proton/wiki)。您也可以在 Proton 问题跟踪器中搜索 GitHub [问题](https://github.com/ValveSoftware/Proton/issues)。以下是我们的客户在 Proton 上运行 Windows 应用程序时遇到的一些具体问题：

**Proton 上的 Godot 应用程序**
+ 如果启用 Amazon Vulkan 捕获层，在 Proton 上运行的基于 Godot 的应用程序可能会遇到黑屏。要缓解此问题，请在流式传输时通过设置环境变量来禁用共享纹理`VK_LAYER_AMZN_BLITSURFACE_SHARED_TEXTURES=0`。

**Proton 上的虚幻引擎应用程序**
+ [如果你在使用 Electra Media Player（虚幻引擎插件）的 Proton 8.x 上遇到问题，我们建议你使用 wine/pull/257 中的修复程序。https://github.com/ValveSoftware/](https://github.com/ValveSoftware/wine/pull/257)

# 设置本地计算机对 Proton 进行故障排除
<a name="troubleshoot-compatibility-setup-local"></a>

 Proton 是一个兼容层，它允许 Windows 应用程序在 Linux 上运行。因此，你必须有一台 Ubuntu 机器来测试和排除故障。如果您没有本地 Ubuntu 计算机，则可以使用 Amazon 设置远程计算机。 EC2为此，请[设置远程机器](troubleshoot-compatibility-setup-remote.md)改为按照中的步骤操作。

## 先决条件
<a name="troubleshoot-compatibility-setup-local-prerequisites"></a>
+ [Ubuntu 22.04](https://releases.ubuntu.com/jammy/) LTS。有关安装说明，你可以使用 Ubuntu 的[安装 U](https://ubuntu.com/tutorials/install-ubuntu-desktop) buntu 桌面教程。
+ 英伟达显卡

## 安装 GPU 驱动程序
<a name="troubleshoot-compatibility-setup-local-install-gpu-drivers"></a>

 安装最新的 GPU 驱动程序可以防止应用程序性能不佳和崩溃。

 **检查您的系统使用的 GPU 驱动程序** 

1.  在终端中运行以下命令：

   ```
   lshw -C display | grep driver
   ```

1.  如果安装了正确的驱动程序，您应该会看到以下输出或类似的输出，其中*<gpu>*是 NVID `nvidia` IA：`configuration: driver=<gpu> latency=0`

**安装最新的 NVIDIA GPU 驱动程序**

按照 [NVIDIA 驱动程序安装](https://documentation.ubuntu.com/server/how-to/graphics/install-nvidia-drivers/)中的说明进行操作。

## 验证 GPU 驱动程序
<a name="troubleshoot-compatibility-setup-local-verify-gpu-drivers"></a>

 确认 GPU 驱动程序已安装且运行正常。验证这一点的一种方法是在终端中运行 [vkcube](https://github.com/krh/vkcube) 应用程序。

1.  使用以下命令安装 `vulkan-tools` apt 软件包。

   ```
   sudo apt install -y vulkan-tools
   ```

1.  运行 `vkcube`。

1.  检查输出。
   +  如果您的系统正确使用了正确的 GPU，您将看到类似于以下内容的输出，其中包含您的 GPU 名称：`Selected GPU 0: AMD Radeon Pro V520 (RADV NAVI12), type: 2`
   +  如果您的应用程序能够正确使用 GPU，则可能会看到类似于以下内容的不同输出：`Selected GPU 0: llvmpipe (LLVM 15.0.7, 256 bits), type: 4`

      在这种情况下，请检查 GPU 驱动程序并在需要时重新安装。

## 后续步骤
<a name="troubleshoot-compatibility-setup-local-next-step"></a>

 当你的本地 Ubuntu 机器准备就绪后，下一步就是设置 Proton。有关说明，请参阅[在 Proton 上进行故障排除](troubleshoot-compatibility-wp-proton.md)。

# 设置一台远程 Amazon EC2 计算机对 Proton 进行故障排除
<a name="troubleshoot-compatibility-setup-remote"></a>

 如果您没有本地 Ubuntu 机器，请改为按照以下说明设置远程计算机。

 在本步骤中，您将使用亚马逊弹性计算云 (Amazon EC2) 设置远程 Ubuntu 计算机，您将使用该云来排除应用程序与 Proton for Amazon Streams 的兼容性问题。 GameLift 本主题介绍如何使用 Ubuntu 22.04 LTS、必要的 GPU 驱动程序和用于可视远程桌面的亚马逊 DCV 服务器来设置 Amazon EC2 实例。

## 使用 Ubuntu 22.04 LTS AMI 启动亚马逊 EC2 实例
<a name="troubleshoot-compatibility-setup-remote-launch-ec2"></a>

1.  在 AWS 管理控制台中导航至 Amazon EC2。

1.  选择**启动实例**。

1.  在**名称**中输入 “Amazon GameLift 直播测试”。

1.  为**应用程序和操作系统映像（亚马逊计算机映像）选择 Ubuntu Server 22.04 LTS (****HVM)**。

1.  **为实例类型选择 **g4dn.2xlarge。****

1.  对于**密钥对（登录）**，如果您想使用 SSH 访问实例，请选择密钥对。我们建议使用带有`AmazonSSMManagedInstanceCore`策略的实例配置文件来连接您的实例 AWS Systems Manager Session Manager。有关更多详细信息，请参阅为[现有 IAM 角色添加会话管理器权限](https://docs.aws.amazon.com/systems-manager/latest/userguide/getting-started-add-permissions-to-existing-profile.html)。

1.  对于**网络设置**，请创建一个新的安全组：

1.  在**安全组名称**中，输入 **DCV**。

1.  添加包含**类型`Custom TCP`、**端口范围**和**源类型的******入站安全组规则**`8443`，`Anywhere`以允许使用 Amazon DCV 进行访问。

1.  将存储空间增加到至少 **256 GiB**，然后选择 **gp3** 作为存储类型。

1.  选择**启动实例**。

您的实例现在应该已启动。

 按照 [Connect to 您的 Linux 实例](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstances.html)中的说明使用 SSH 或连接到该实例 AWS Systems Manager Session Manager。

## 安装 GPU 驱动程序
<a name="troubleshoot-compatibility-setup-remote-install-gpu"></a>

### g4dn-NVIDIA GPU
<a name="troubleshoot-compatibility-setup-remote-install-gpu-nvidia"></a>

 通过运行以下命令安装其他模块和 Linux 固件：

```
sudo apt install linux-modules-extra-aws linux-firmware 

# Install the AWS CLI required for NVIDIA driver installation 
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" 
sudo apt install unzip
unzip awscliv2.zip 
sudo ./aws/install
```

 按照在 Linux 上[安装 NVIDIA 驱动程序中适用于 Ubuntu 和 Debian 的 NVIDIA GRID 驱动程序](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-nvidia-driver.html)中的说明进行操作。

## 设置用户环境
<a name="troubleshoot-compatibility-setup-remote-user-env"></a>

通过运行以下命令设置您的用户环境，使其可以使用 GPU。这会做以下事情：
+ 将您添加到允许您访问视频设备的`video`群`render`组，以及允许您访问渲染设备的群组。
+ 安装 AWS CLI，这是 NVIDIA 驱动程序以及从 Amazon S3 下载应用程序或游戏所必需的。

```
sudo adduser user 

# Add the current user to the video and render group 
sudo usermod -a -G video user 
sudo usermod -a -G render user 
sudo adduser user sudo 

# Install the AWS CLI 
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" 
sudo apt install unzip 
unzip awscliv2.zip 
sudo ./aws/install 

sudo reboot
```

## 安装和配置 Amazon DCV
<a name="troubleshoot-compatibility-setup-remote-nice-dcv"></a>

 使用 SSH 重新连接到实例，或者 AWS Systems Manager Session Manager 按照在 [Linux 上安装 Ubuntu 版 Amazon DCV 服务器中的说明进行](https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing-linux.html)操作。
+  确认服务器配置正确，如文档中所述。
+  按照为 NVIDIA GPU [安装和配置 NVIDIA 驱动程序](https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing-linux-prereq.html#linux-prereq-gpu)中的步骤操作。
+  按照《[安装服务器》指南（导航至 Ubuntu 选项卡）的第 7 步](https://docs.aws.amazon.com/dcv/latest/adminguide/setting-up-installing-linux-server.html)中所述，将 Amazon DCV 用户添加到视频群组。

无需安装 Amazon DCV 服务器的任何可选部件。

完成后，运行以下命令启动 Amazon DCV 服务器：

```
sudo systemctl start dcvserver 
sudo systemctl enable dcvserver
```

## 使用亚马逊 DCV 客户端连接到 Ubuntu 服务器
<a name="troubleshoot-compatibility-setup-remote-nice-dcv-connect"></a>

 通过运行以下命令重新连接到您的 Ubuntu 实例并为用户创建会话：

```
sudo dcv create-session --owner user --user user my-session --type console
```

 现在，您可以使用 Amazon DCV 客户端使用其公有 IP 地址访问您的 Ubuntu 实例。当您启动 Amazon DCV 客户端时，会出现一个窗口，允许您通过可视显示屏访问您的 Ubuntu 实例。

![\[当您启动 Amazon DCV 客户端时，会出现一个窗口，允许您通过可视显示屏访问您的 Ubuntu 实例。\]](http://docs.aws.amazon.com/zh_cn/gameliftstreams/latest/developerguide/images/troubleshoot-compatibility-setup-remote-dcv.png)


## 验证 GPU 驱动程序
<a name="troubleshoot-compatibility-setup-remote-verify-gpu"></a>

 确认 GPU 驱动程序已安装且运行正常。验证这一点的一种方法是在终端中运行 [vkcube](https://github.com/krh/vkcube) 应用程序。

1.  使用以下命令安装 `vulkan-tools` apt 软件包。

   ```
   sudo apt install -y vulkan-tools
   ```

1.  运行 `vkcube`。

1.  检查输出。
   +  如果您的系统正确使用了正确的 GPU，您将看到类似于以下内容的输出，其中包含您的 GPU 名称：`Selected GPU 0: AMD Radeon Pro V520 (RADV NAVI12), type: 2`
   +  如果您的应用程序能够正确使用 GPU，则可能会看到类似于以下内容的不同输出：`Selected GPU 0: llvmpipe (LLVM 15.0.7, 256 bits), type: 4`

      在这种情况下，请检查 GPU 驱动程序并在需要时重新安装。

## 设置 Podman（仅限 Proton）
<a name="troubleshoot-compatibility-setup-remote-podman"></a>

如果你使用的是 Proton 运行时，你必须安装 P [odman](https://wiki.debian.org/Podman)，这是一个 Proton 构建过程使用的容器。在终端中完成以下步骤。

1.  安装 Podman，这是一款 Proton 构建过程使用的容器。

   ```
   sudo apt install podman
   ```

1.  在文件中`/etc/subgid`和 `/etc/subgid` 

   1. 确认文件中列出了您的 Linux 计算机用户名和 ID。您可以打开文件，也可以使用`cat`命令查看文件中的内容。格式示例：`test:165536:65536`，其中`test`对应于您的用户名。

   1.  如果未列出，请将其添加进去。格式示例：`test:165536:65536`，其中`test`对应于您的用户名。

   ```
   $ cat /etc/subuid
                 ceadmin:100000:65536
                 test:165536:65536
                 
                 $ cat /etc/subgid
                 ceadmin:100000:65536
                 test:165536:65536
   ```

    有关更多信息，请参阅 [Podman 文档中的基本设置和在无根环境中使用](https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md#basic-setup-and-use-of-podman-in-a-rootless-environment) Podman。

## 后续步骤
<a name="troubleshoot-compatibility-setup-remote-setup-local-next-step"></a>

 现在，您已经设置好了 Amazon EC2 实例和环境，可以解决与 Amazon GameLift Streams 的兼容性问题。下一步是设置 Proton。有关说明，请参阅[在 Proton 上进行故障排除](troubleshoot-compatibility-wp-proton.md)。

# 对 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)的帮助。