ARM-software / patrace

MIT License
71 stars 36 forks source link

recording a patrace #44

Closed pemgithub closed 7 months ago

pemgithub commented 2 years ago

I tried recording a patrace for some games like Diablo Immortal and Genshin Impact. Genshin Impact crashes at the end of the loading screen. Diablo Immortal the game plays but the trace stops recording after the loading screen. Are there some tricks for basic use recording games?

per-mathisen-arm commented 2 years ago

We've managed to trace both in the past. Diablo Immortal might switch to Vulkan, perhaps? You might want to check its settings. Check logcat for crash logs and if you find anything that looks interesting, please post it here.

pemgithub commented 2 years ago

I'll need to check the logcat whether Diablo Immortal is using Vulkan. There appears to be no graphics settings for Vulkan vs OpenGL ES in the Android app.

What about Asphalt 9? I recorded a 2.4G trace, but it does not replay. Is there some trick like we need to use particular options in terms of using the PARetrace android app to record, and in the replay.

To record I just ran adb shell settings put global gpu_debug_app com.gameloft.android.ANMP.GloftA9HM, open the game, run it for a minute or so, then close the game.

To replay, I used: { "file": "/data/apitrace/com.gameloft.android.ANMP.GloftA9HM/com.gameloft.android.ANMP.GloftA9HM.1.pat", "offscreen": false, "overrideResolution": true, "overrideHeight": 1080, "overrideWidth": 3200, "forceSingleWindow": false, "multithread": true }

adb push patrace/Asphalt9.json //data/data/com.arm.pa.paretrace/patrace-settings.json adb shell am start -n com.arm.pa.paretrace/.Activities.RetraceActivity --es jsonData //data/data/com.arm.pa.paretrace/patrace-settings.json

pemgithub commented 2 years ago

I'm now able to replay a Genshin Impact trace. However, the loopTimes feature doesn't seem to work...

I tried using the following patrace-settings.json. It plays the trace once, but does not loop frames 2976-3352:

{
   "file": "/data/local/tmp/traces/OGL_GenshinImpact/strm_0..3352.pat",
   "offscreen": false,
   "overrideResolution": true,
   "overrideHeight": 1080,
   "overrideWidth": 3200,
   "forceSingleWindow": false,
   "multithread": true,
   "frames": "2976-3352",
   "_snapshotCallset": "2976-3352/frame",
   "_snapshotPrefix": "/data/data/com.arm.pa.paretrace/dumpFrames/frame_",
   "landscape": true,
   "preload": true,
   "storeProgramInformation": true,
   "loopTimes": 10
}

Note I used the following to png's for 2976-3352. These are frames after the actual game scene is loaded (frames 1-2975 are the main menu and loading screen).

{
   "file": "/data/local/tmp/traces/OGL_GenshinImpact/strm_0..3352.pat",
   "offscreen": false,
   "overrideResolution": true,
   "overrideHeight": 1080,
   "overrideWidth": 3200,
   "forceSingleWindow": false,
   "multithread": true,
   "frames": "2976-3352",
   "snapshotCallset": "2976-3352/frame",
   "snapshotPrefix": "/data/data/com.arm.pa.paretrace/dumpFrames/frame_",
   "landscape": true,
   "preload": true,
   "storeProgramInformation": true,
}

Aside, Is there a discord channel (or other chat) to ask general user questions like this?

pemgithub commented 2 years ago
adb shell am start -n com.arm.pa.paretrace/.Activities.RetraceActivity --es jsonData //data/data/com.arm.pa.paretrace/patrace-settings.json --es resultFile //data/data/com.arm.pa.paretrace/result.json --ei frame_start 2976 --ei frame_end 3352
{
   "file": "/data/local/tmp/traces/OGL_GenshinImpact/strm_0..3352.pat",
   "offscreen": false,
   "overrideResolution": true,
   "overrideHeight": 1080,
   "overrideWidth": 3200,
   "forceSingleWindow": false,
   "multithread": true,
   "frames": "2976-3352",
   "_snapshotCallset": "2976-3352/frame",
   "_snapshotPrefix": "/data/data/com.arm.pa.paretrace/dumpFrames/frame_",
   "preload": true,
   "landscape": true,
   "storeProgramInformation": true,
   "loopTimes": 10
}

From adb logcat:

paretrace64: retracer.cpp,1408: ================== Start timer (Frame: 2976) ==================
paretrace64: retracer.cpp,1243: Executing rollback 0 / 10 times - 7 / 0 secs
paretrace64: retrace_gles_auto.cpp,10173: map buffer failed: 0x0501! binding is 0x8f37, access is 0x003a, buffer is 277
paretrace64: retrace_gles_auto.cpp,10173: map buffer failed: 0x0501! binding is 0x8f37, access is 0x003a, buffer is 2934
paretrace64: [c9779103,f2976] Trying to copy client side buffer 23210, but failed to fetch GL_COPY_WRITE_BUFFER buffer 277
paretrace64: trace_executor.cpp,611: Results written to //data/data/com.arm.pa.paretrace/result.json

If I remove ("loopTimes": 10) from patrace-settings.json then it doesn't get the above error. So the trace seems to quit when it tries to loop.

per-mathisen-arm commented 2 years ago

We have successfully traced and replayed Asphalt 9 in the past as well, it should work with multithreaded replay: If not, please post whatever errors / crash backtrace you get. The loop feature is very tricky - you need to find a frame range that works by trial and error, and for some traces it will not work at all. It does no save/restore of GLES state, so you are entirely reliant on the app re-setting all the needed state on its own for the first frame. Sometimes it helps to start at a natural scene boundary.