

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 針對 Proton 上的相容性進行故障診斷
<a name="troubleshoot-compatibility-wp-proton"></a>

 在此步驟中，您將在自己的機器上設定 Proton，以便疑難排解 Amazon GameLift Streams 應用程式與 Proton 之間的相容性問題。在沒有 Amazon GameLift Streams 伺服器的模擬環境中執行應用程式，可協助您識別應用程式和執行時間環境的特定問題。

## 先決條件
<a name="troubleshoot-compatibility-wp-proton-prereq"></a>
+  Ubuntu 22.04 LTS 已安裝 GPU 驅動程式。如需說明，請參閱 [設定本機機器](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 [ GitHub 儲存庫測試的 Proton](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 複製需要一些時間。有許多子模組可供下載，總計數 GB。

    在您的終端機中，執行`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 (Unreal Engine 外掛程式） 的問題，建議您使用 https：//[https://github.com/ValveSoftware/wine/pull/257](https://github.com/ValveSoftware/wine/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 的 DebuggingWine ](https://wiki.winehq.org/Wine_Developers_Guide/Debugging_Wine)指南」。如果您在應用程式端無法修正的日誌中發現 Proton 或 Honey 錯誤，請聯絡您的 AWS 客戶經理或在 [AWS re：Post](https://repost.aws/tags/TAOU7EpUOuTQSSWmIHCfb2fQ/amazon-gamelift-streams) 中張貼問題，以協助進一步偵錯。