hexstr / UnityFPSUnlocker

为unity-il2cpp提供在手机上设置FPS的模块
MIT License
356 stars 44 forks source link

[BUG] 手机上首次加载游戏不能正确设置帧率 #49

Closed qiuyue0 closed 1 year ago

qiuyue0 commented 1 year ago

问题描述

在雷电模拟器上一切正常,公主连结可以正常开启120,但是手机上首次加载游戏不能正确设置帧率。

机型及配置

机型:红米K40 MIUI14.0.23.3.27DEV magisk:ed37ddd5-alpha (25205) 模块版本:v3.5

TargetList.json正确放置在/data/local/tmp image

TargetList.json如下:

{
  "global": {
    "delay": 10,
    "mod_opcode": false,
    "fps": 120
  },
  "custom": {
    "com.bilibili.priconne": {
      "delay": 20,
      "fps": 120,
      "mod_opcode": true
    }
  }
}

日志文件

打开公主连结后,日志如下:

$ logcat -s UnityFPSUnlocker:V
--------- beginning of main
04-14 15:54:07.216  9156  9175 D UnityFPSUnlocker: [UnityFPSUnlocker][arm64] Starting...
04-14 15:54:07.216  9156  9175 D UnityFPSUnlocker: delay: 20 | framerate: 120 | modify_opcode: 0
04-14 15:54:09.995  9156  9175 D UnityFPSUnlocker: ***** begin *****
04-14 15:54:09.996  9156  9175 D UnityFPSUnlocker: Failed, not support this game.
04-14 15:55:37.759 15328 15340 D UnityFPSUnlocker: [UnityFPSUnlocker][arm64] Starting...
04-14 15:55:37.759 15328 15340 D UnityFPSUnlocker: delay: 20 | framerate: 120 | modify_opcode: 0
04-14 15:55:44.759 15328 15340 D UnityFPSUnlocker: ***** begin *****
04-14 15:55:44.759 15328 15340 D UnityFPSUnlocker: set_targetFrameRate: 120
04-14 15:55:44.759 15328 15340 D UnityFPSUnlocker: ***** finished *****

这里有个两个问题:

  1. 在第一次打开公主连结的时候,显示Failed, not support this game.,重启游戏后正常set_targetFrameRate: 120
  2. 我第二次已经将delay修改为30s,脚本没有立即生效。

两次启动不同的点在于游戏第一次启动会黑屏大概20s,而程序在15:54:07启动后2s就抛出not support。 但雷电首次启动也会黑屏一段时间,不会影响加载。

# 0 logcat -s UnityFPSUnlocker
--------- beginning of main
--------- beginning of system
04-14 16:32:36.987  1769  1781 D UnityFPSUnlocker: [Listener::Register] Registered: wd: 1 /data/local/tmp/TargetList.json
04-14 16:32:36.987  1769  1781 D UnityFPSUnlocker: [LoadConfig] custom_list: 1
04-14 16:32:36.987  1769  1781 D UnityFPSUnlocker: [LoadConfig] global_cfg:
04-14 16:32:36.987  1769  1781 D UnityFPSUnlocker:      delay: 10 | fps: 120 | mod_opcode: 0
04-14 16:32:37.044  1811  1827 D UnityFPSUnlocker: [Listener::Register] Registered: wd: 1 /data/local/tmp/TargetList.json
04-14 16:32:37.045  1811  1827 D UnityFPSUnlocker: [LoadConfig] custom_list: 1
04-14 16:32:37.045  1811  1827 D UnityFPSUnlocker: [LoadConfig] global_cfg:
04-14 16:32:37.045  1811  1827 D UnityFPSUnlocker:      delay: 10 | fps: 120 | mod_opcode: 0
04-14 16:37:56.744  3901  3910 D UnityFPSUnlocker: [UnityFPSUnlocker][x86] Starting...
04-14 16:37:56.744  3901  3910 D UnityFPSUnlocker: delay: 10 | framerate: 120 | modify_opcode: 1
04-14 16:38:06.783  3901  3910 D UnityFPSUnlocker: ***** begin *****
04-14 16:38:06.784  3901  3910 D UnityFPSUnlocker: set_targetFrameRate: 120
04-14 16:38:06.784  3901  3910 D UnityFPSUnlocker: ***** finished *****

这里看到雷电加载是正常的,但是与手机一样,不能修改后立即生效。

问题汇总

  1. 配置文件保存后不会动态加载
  2. 手机端首次开启公主连结提示Failed, not support this game.,重启游戏后正常
hexstr commented 1 year ago

1.这个看起来是TargetLst.json首先被重命名为TargetLst.json.bak然后重新写入了新的TargetLst.json导致file_watch失效,换个软件编辑试试 2.看起来sleep(delay)没有生效,我要调试一下

qiuyue0 commented 1 year ago

1.这个看起来是TargetLst.json首先被重命名为TargetLst.json.bak然后重新写入了新的TargetLst.json导致file_watch失效,换个软件编辑试试 2.看起来sleep(delay)没有生效,我要调试一下

测试了一下,1确实是mt管理器的问题,但是只要用mt管理器编辑过一次,哪怕关闭了mt管理器的自动生成备份,之后无论使用什么进行编辑,都会报错[Listener::Register] File exists,需要重启手机才能恢复。

TenmaOishii commented 1 year ago

我的手机也出现了类似2的问题,不过开机第一次加载app可以120,但是只要手机杀后台或者手动关闭app之后再次打开app,就没法正常120,需要重启app一次。查看日志发现在关闭app的时候脚本也会跑一次,那结果就是Failed。

hexstr commented 1 year ago

@TenmaOishii 你用的不会也是miui吧?

TenmaOishii commented 1 year ago

@TenmaOishii 你用的不会也是miui吧?

用的红魔OS

hexstr commented 1 year ago

试一下3.6

TenmaOishii commented 1 year ago

感谢!3.6后我这边问题解决了,不知道楼主怎么样。

qiuyue0 commented 1 year ago

3.6已修复,感谢