Turn snap-back smoothing and gamepad turning feel (r42); close several slow memory accumulations; Mac App mouse, language switch and warm-up list
This commit is contained in:
@@ -51,7 +51,8 @@ static NSDate *g_t0; // 本次启动时刻(dm_sharelog_boot) | Time of thi
|
||||
static NSURL *build_file(void) {
|
||||
NSFileManager *fm = NSFileManager.defaultManager;
|
||||
NSString *doc = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
|
||||
NSData *cur = [NSData dataWithContentsOfFile:[doc stringByAppendingPathComponent:@"boot.txt"]], *prev = [NSData dataWithContentsOfFile:[doc stringByAppendingPathComponent:@"boot.previous.txt"]];
|
||||
NSData *(^rd)(NSString *) = ^NSData *(NSString *n) { return [NSData dataWithContentsOfFile:[doc stringByAppendingPathComponent:n] options:NSDataReadingMappedIfSafe error:nil]; }; // 映射着读:日志没有字节封顶,整读进内存再拼、再洗各拷一遍,峰值是日志的四倍 | read through a mapping: the log has no byte cap, and reading it whole into memory, then joining and scrubbing with one copy each, peaks at four times the log size
|
||||
NSData *cur = rd(@"boot.txt"), *prev = rd(@"boot.previous.txt");
|
||||
NSDictionary *inf = NSBundle.mainBundle.infoDictionary; NSString *build = [inf[@"CFBundleVersion"] description] ?: @"未知";
|
||||
NSDateFormatter *df = [NSDateFormatter new]; df.dateFormat = @"yyyy-MM-dd HH:mm:ss ZZZ";
|
||||
char hw[64] = "未知"; size_t hn = sizeof hw; sysctlbyname("hw.machine", hw, &hn, NULL, 0);
|
||||
@@ -73,11 +74,11 @@ static NSURL *build_file(void) {
|
||||
[fm removeItemAtPath:dir error:nil]; [fm createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
df.dateFormat = @"yyyyMMdd_HHmmss";
|
||||
NSString *p = [dir stringByAppendingPathComponent:[NSString stringWithFormat:@(dm_ui("dmShareLogFile")), build, [df stringFromDate:NSDate.date]]];
|
||||
out = [scrub_home(out) mutableCopy];
|
||||
if (![out writeToFile:p atomically:YES]) { plog("诊断日志:【红】导出文件写不进 %s", p.UTF8String); return nil; }
|
||||
plog("诊断日志:已打包 %s(%lu 字节:本局 %lu、上一局 %s)", p.lastPathComponent.UTF8String, (unsigned long)out.length, (unsigned long)cur.length,
|
||||
NSData *fin = scrub_home(out);
|
||||
if (![fin writeToFile:p atomically:YES]) { plog("诊断日志:【红】导出文件写不进 %s", p.UTF8String); return nil; }
|
||||
plog("诊断日志:已打包 %s(%lu 字节:本局 %lu、上一局 %s)", p.lastPathComponent.UTF8String, (unsigned long)fin.length, (unsigned long)cur.length,
|
||||
prev ? [NSString stringWithFormat:@"%lu", (unsigned long)prev.length].UTF8String : "没有");
|
||||
if (getenv("DM_TEST_SHARELOG_CLOSE")) [out writeToFile:[doc stringByAppendingPathComponent:@"sharelog_test.txt"] atomically:YES];
|
||||
if (getenv("DM_TEST_SHARELOG_CLOSE")) [fin writeToFile:[doc stringByAppendingPathComponent:@"sharelog_test.txt"] atomically:YES];
|
||||
return [NSURL fileURLWithPath:p];
|
||||
}
|
||||
static UIViewController *top_vc(void) { // 同 front_ios.m 系统输入框找宿主的顺序:主窗口 → 前台活跃场景的窗口 → 任一窗口,再顺着已弹出的往上找 | Same order as front_ios.m's system input box uses to find its host: main window → a window of the foreground active scene → any window, then walk up through what is already presented
|
||||
|
||||
@@ -1055,7 +1055,7 @@ int front_text_input(const char *title, const char *sub, const char *guide, cons
|
||||
tf.text = [tf.text substringWithRange:keep];
|
||||
}] forControlEvents:UIControlEventEditingChanged];
|
||||
}];
|
||||
void (^finish)(int) = ^(int ok) { g_text_alert = nil; g_text_alert_finish = nil; if (ok) text = a.textFields.firstObject.text;
|
||||
void (^finish)(int) = ^(int ok) { UIAlertController *sa = wa; g_text_alert = nil; g_text_alert_finish = nil; if (ok) text = sa.textFields.firstObject.text; // 弱引用对话框:按钮回调 → finish → 对话框 → 按钮 是个环,对话框每弹一次留一个 | weak reference to the dialog: button callback -> finish -> dialog -> button is a cycle, leaving one dialog behind every time it is shown
|
||||
// 名字留空点确定 = 随机取名:我们自己抽一个(dm_namegen.c,约 1.8 万种、与已有角色重名就再抽),当作玩家输入的名字返回,走游戏原本的起名校验;只填进名字框不自动接受(同原版「随机名字」键,玩家看到再点创建)。
|
||||
// 原先发原版「随机名字」键,那是按职业在 12 个名字里依次轮,容易撞
|
||||
// Leaving the name empty and tapping OK = random naming: we draw one ourselves (dm_namegen.c, about 18,000 variants; redraw if it collides with an existing character), return it as the name the player typed, and go through the game's original name validation; it is only filled into the name field and not auto-accepted (same as the original game's 「随机名字」(Random Name) key: the player sees it and then taps create).
|
||||
@@ -1353,6 +1353,7 @@ static void touch_script_start(void) {
|
||||
while(next<steps.count && [steps[next][0] doubleValue]<=now) {
|
||||
NSArray *f=steps[next++]; NSString *op=f.count>1?f[1]:@""; aw_on=0;
|
||||
if([op isEqualToString:@"shot"]) window_shot(f[2]);
|
||||
else if([op isEqualToString:@"burst"] && f.count>=4) { void dm_gfx_burst(int, const char *); dm_gfx_burst([f[2] intValue], [doc stringByAppendingPathComponent:f[3]].UTF8String); LOG("[script] burst %d 帧 → %s", [f[2] intValue], [f[3] UTF8String]); }
|
||||
else if([op isEqualToString:@"tshot"]) [g_touch_view captureTouchLayer:[doc stringByAppendingPathComponent:f[2]]]; // 操作层 PNG + 控件/当前技能元数据 JSON | Control layer PNG + JSON metadata of widgets / current skills
|
||||
// type <文字>:往弹着的输入对话框里敲字——走 UITextField 的 insertText:(系统键盘上屏走的同一个入口,照样触发输入规则的拦截);
|
||||
// alert ok|cancel:点对话框的「确定」/「取消」。两者都只在对话框弹着时有效,没弹着就记一行日志
|
||||
|
||||
@@ -17,6 +17,8 @@ static int g_nofile_was, g_nofile_now; // 启动时的文件描述符软上限
|
||||
#include <dirent.h>
|
||||
#include <libkern/OSCacheControl.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <os/proc.h>
|
||||
#include <mach/mach.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
@@ -689,6 +691,8 @@ static void host_start(void) {
|
||||
{ extern int dm_shader_prep_begin(void (^)(void)); static int asked; if (!asked) { asked = 1; if (dm_shader_prep_begin(^{ host_start(); })) return; } }
|
||||
#endif
|
||||
g_host_up = 1; plog("boot: 场景到前台,起宿主(进程已活 %.1f ms)", since_start());
|
||||
{ const char *mw = getenv("DM_TEST_MEMWARN"); // 测试开关 DM_TEST_MEMWARN=<秒>:起宿主后这么多秒,照系统的调法调一次内存告警回调(验那一行日志;系统真发告警的时机造不出来) | test switch DM_TEST_MEMWARN=<seconds>: this many seconds after the host starts, call the memory-warning callback once the way the system does (to check that log line; the moment the system really sends a warning cannot be staged)
|
||||
if (mw && atof(mw) > 0) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(atof(mw) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ UIApplication *app = UIApplication.sharedApplication; [app.delegate applicationDidReceiveMemoryWarning:app]; }); }
|
||||
boot_begin(); // 覆盖层、宿主装载与预取:也等到这里才做(在后台线程,和后面的界面收尾并行) | overlay, host loading and prefetch: also deferred until here (on a background thread, in parallel with the UI wrap-up that follows)
|
||||
front_ios_lifecycle_install(); // 过热 / 不自动锁屏 / 亮度(窗口与焦点在 SceneDelegate) | overheating / no auto-lock / brightness (window and focus are in SceneDelegate)
|
||||
run_boot(); // 宿主线程自己写 DONE | The host thread writes DONE itself
|
||||
@@ -948,6 +952,19 @@ static void bg_relaunch_test(void) {
|
||||
|
||||
@implementation App
|
||||
- (void)applicationWillTerminate:(UIApplication *)a { if (g_host_up) dm_host_shutdown("iOS App 终止"); }
|
||||
// 系统内存告警:只记一行,不放任何缓存。用途:玩家被系统按内存终止前不会有任何通知,上一局日志里至少留下前兆与当时的几项读数
|
||||
// (常驻、显卡已分配、游戏主堆余量是上次每 300 帧读到的值、离系统内存上限还有多少)。一局最多记 50 行
|
||||
// System memory warning: log one line only, release no cache. Purpose: a player gets no notice before the system terminates the app for memory, so the previous session's log at least keeps the precursor and a few readouts at that moment
|
||||
// (resident size, GPU allocated, main-heap free space as last read every 300 frames, and how far from the system memory limit). At most 50 lines per session
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)a {
|
||||
static int n; if (++n > 50) return;
|
||||
task_vm_info_data_t vi; mach_msg_type_number_t cnt = TASK_VM_INFO_COUNT; unsigned long long fp = 0;
|
||||
if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t)&vi, &cnt) == KERN_SUCCESS) fp = vi.phys_footprint >> 20;
|
||||
unsigned long long h[3] = {0, 0, 0}, gpu = 0; void dm_guest_heap_last(unsigned long long *); unsigned long long mtl_gpu_allocated_mb(void);
|
||||
if (g_host_up) { dm_guest_heap_last(h); gpu = mtl_gpu_allocated_mb(); }
|
||||
plog("【内存告警】系统发来内存告警(本局第 %d 次,进程已活 %.0f 秒,applicationState=%ld):常驻 %llu MB,显卡已分配 %llu MB,游戏堆 %llu MB 余量 %llu MB 最大可分配块 %llu KB,离系统内存上限还有 %llu MB",
|
||||
n, since_start() / 1000.0, (long)a.applicationState, fp, gpu, h[0], h[1], h[2], (unsigned long long)(os_proc_available_memory() >> 20));
|
||||
}
|
||||
- (void)application:(UIApplication *)a handleEventsForBackgroundURLSession:(NSString *)ident completionHandler:(void (^)(void))done {
|
||||
plog("boot: 系统交来后台下载会话 %s 的事件(applicationState=%ld,宿主%s)", ident.UTF8String, (long)a.applicationState, g_host_up ? "在跑" : "没起");
|
||||
if ([ident hasSuffix:@".bgtest"]) { plog("后台测试会话:接回"); (void)bg_test_session(); done(); return; }
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# 连拍分析:burst_sad.py <连拍目录>。连拍由触点脚本步骤「burst <帧数> <目录名>」产出(nvn_mtl.m burst_grab),目录在 App 的 Documents 下。
|
||||
# 每对相邻帧:高通后去掉屏幕中心人物那块,在 ±R 像素内找绝对差最小的整像素位移(环境变量 R,缺省 14;30 帧档每帧位移大,给 26);
|
||||
# 同时打印 meta.txt 里记的本地玩家逻辑位移(格)。相位相关在草地这类弱纹理上会读成 0,所以用块匹配
|
||||
# Burst analysis: burst_sad.py <burst directory>. A burst is produced by the touch-script step "burst <frames> <directory name>" (nvn_mtl.m burst_grab); the directory is under the App's Documents.
|
||||
# For each pair of adjacent frames: after a high-pass, with the character block at the screen centre removed, find the whole-pixel displacement with the smallest absolute difference within +-R pixels (environment variable R, default 14; at 30 fps the per-frame displacement is larger, use 26);
|
||||
# the logical displacement of the local player (tiles) recorded in meta.txt is printed alongside. Phase correlation reads 0 on weak textures such as grass, hence block matching
|
||||
import os,sys,numpy as np
|
||||
from PIL import Image, ImageFilter
|
||||
d=sys.argv[1]; L=open(d+'/meta.txt').read().split('\n'); n=int(L[0].split()[-1]); W=int(L[0].split()[1]); L=L[1:n+1]
|
||||
P=[(float(l.split()[8]),float(l.split()[10])) for l in L] if len(L[0].split())>8 else None
|
||||
def hp(k):
|
||||
a=np.frombuffer(open(f'{d}/f{k:03d}.raw','rb').read(),dtype=np.uint8).reshape(W,W,4)[:,:,:3].mean(2)
|
||||
im=Image.fromarray(a.astype(np.uint8)); b=np.asarray(im.filter(ImageFilter.GaussianBlur(6)),dtype=float); return a-b
|
||||
H=[hp(k) for k in range(n)]; c=W//2; R=14
|
||||
R=int(os.environ.get("R","14")); mask=np.ones((W,W),bool); mask[c-160:c+120,c-120:c+120]=False; mask[:R+1]=mask[-R-1:]=False; mask[:,:R+1]=mask[:,-R-1:]=False
|
||||
ys,xs=np.nonzero(mask)
|
||||
out=[]
|
||||
for k in range(n-1):
|
||||
a=H[k][ys,xs]; best=None
|
||||
for dy in range(-R,R+1):
|
||||
for dx in range(-R,R+1):
|
||||
v=np.abs(a-H[k+1][ys+dy,xs+dx]).mean()
|
||||
if best is None or v<best[0]: best=(v,dx,dy)
|
||||
out.append((best[1],best[2]))
|
||||
for k,(dx,dy) in enumerate(out):
|
||||
lp='' if not P else ' 逻辑位移 %+.2f,%+.2f'%(P[k+1][0]-P[k][0],P[k+1][1]-P[k][1])
|
||||
print(f'{k:3d}→{k+1:3d} 画面位移 {dx:+d},{dy:+d}{lp}')
|
||||
@@ -0,0 +1,13 @@
|
||||
# 转向平滑逐帧位移表:turn_trace.py <boot.txt> [起始行号 [行数]]。读宿主日志里的「转向帧迹」行(DM_TEST_TURN_TRACE=1,dm_turnsmooth.c),
|
||||
# 画出来的位置 = 外推坐标 + 误差(1/65536 格);换成屏幕方向的位移(格):横 = (dx − dy),纵 = (dx + dy) / 2(等距投影,纵向压一半)。
|
||||
# 输出每帧:序号 横位移 纵位移 位移模 | 外推坐标自身的位移模(= 不做平滑时画面的走法)| 误差模 在走 外推拍比例
|
||||
# Per-frame displacement table for turn smoothing: turn_trace.py <boot.txt> [start line [line count]]. Reads the turn-trace lines in the host log (DM_TEST_TURN_TRACE=1, dm_turnsmooth.c);
|
||||
# the drawn position = extrapolated coordinates + error (1/65536 tile); converted to displacement in screen directions (tiles): horizontal = (dx - dy), vertical = (dx + dy) / 2 (isometric projection, vertical halved).
|
||||
# Output per frame: index, horizontal displacement, vertical displacement, displacement magnitude | displacement magnitude of the extrapolated coordinates alone (= how the picture would move without smoothing) | error magnitude, walking, extrapolated tick fraction
|
||||
import sys,re
|
||||
rows=[tuple(float(v) for v in m.groups()) for m in (re.search(r'转向帧迹 (-?\d+) (-?\d+) (-?\d+) (-?\d+) (\d) ([\d.]+) ([\d.]+)',l) for l in open(sys.argv[1],encoding='utf-8',errors='replace')) if m]
|
||||
a=int(sys.argv[2]) if len(sys.argv)>2 else 0; n=int(sys.argv[3]) if len(sys.argv)>3 else len(rows)
|
||||
def scr(dx,dy): return (dx-dy)/65536,(dx+dy)/131072
|
||||
for i in range(max(1,a),min(len(rows),a+n)):
|
||||
p,q=rows[i-1],rows[i]; sx,sy=scr(q[0]+q[2]-p[0]-p[2],q[1]+q[3]-p[1]-p[3]); rx,ry=scr(q[0]-p[0],q[1]-p[1])
|
||||
print('%4d 画面 %+.3f %+.3f 模 %.3f | 不平滑 %+.3f %+.3f 模 %.3f | 误差 %.3f 在走 %d 外推 %.2f'%(i,sx,sy,(sx*sx+sy*sy)**.5,rx,ry,(rx*rx+ry*ry)**.5,((q[2]/65536)**2+(q[3]/65536)**2)**.5,int(q[4]),q[5]))
|
||||
@@ -61,6 +61,7 @@ dm/host/dm_cursor* a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 b
|
||||
dm/host/hle_touch* a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd
|
||||
dm/host/touch_mac.c a c j s sb pg2 vt1 rw1
|
||||
dm/ios/tools/touch_layout.py a c f g h j k m n p q s t u sb cb sl1 me1 me2 pg2 vt1 vf1 vf2 rw1 rw2 kba bd pk pvb
|
||||
dm/ios/Sources/dm_sharelog.m shl
|
||||
dm/ios/Sources/front_ios.m a c f g h j m n p q s t u sb cb sl1 sl2 me1 me2 pg2 vt1 rw1 bd pk
|
||||
dm/ios/Sources/* a e pk rf2
|
||||
dm/ios/NativeHUD/* a f pk bd g q
|
||||
|
||||
|
@@ -668,6 +668,13 @@ def groups():
|
||||
g.item("「综合技能」页长按另一个技能","开绑定框",r"OpenPanel ButtonBindingModal"); g.hold(301,114,1.3); g.shot()
|
||||
g.tap(P(120,200),1.5); g.tap(P(615,17),1.2)
|
||||
gs.append(g)
|
||||
# shl 局:暂停菜单「分享诊断日志」。测试开关让分享面板弹出 3 秒后自己收起(真机截不到系统弹层,只读日志);导出的文件另拷一份到容器 Documents/sharelog_test.txt
|
||||
# shl run: pause menu "Share diagnostic log". A test switch lets the share sheet dismiss itself 3 seconds after it appears (system overlays cannot be captured on a device, only the log is read); the exported file is also copied to Documents/sharelog_test.txt in the container
|
||||
g=G("shl","DM_TEST_SHARELOG_CLOSE=3"); g.sect("sharelog",0); g.enter(); g.tap("@menu",1.4); g.tap(P(551,17))
|
||||
g.item("暂停菜单点「分享诊断日志」","两份日志打成一个文件(本局那份非空)、分享面板弹出",r"诊断日志:已打包 \S+(\d+ 字节:本局 [1-9]\d*、[^\n]*\n(?:[^\n]*\n){0,40}?[^\n]*诊断日志:分享面板已弹出"); g.at("tap_ui MessageLog@PauseLayoutGarden 3",2.5); g.shot()
|
||||
g.item("等 3 秒","分享面板到点自己收起",r"到点收起分享面板"); g.wait(3.0); g.shot()
|
||||
g.item("再点一次「分享诊断日志」","又能打包(上一次收起后没卡在忙状态)",r"诊断日志:已打包"); g.at("tap_ui MessageLog@PauseLayoutGarden 3",5.5); g.shot()
|
||||
gs.append(g)
|
||||
# i 局:雇佣兵(第一幕卡夏;第二幕格雷兹是同一个雇佣面板)。最小步骤来自一条真问题:雇佣名单里同一行连点几下、雇成之后面板栈的计数没清,摇杆和技能钮回不来
|
||||
# i run: hiring a mercenary (Act 1 Kashya; Act 2 Greiz is the same hire panel). The minimal steps come from a real problem: tapping the same row of the hire list several times, the panel stack count was not cleared after the hire succeeded, and the stick and skill buttons did not come back
|
||||
g=G("i","DM_TEST_GOLD=200000 DM_TEST_WORLD_GO=near2:1:c150@200"); g.sect("hire",0); g.enter(1)
|
||||
|
||||
Reference in New Issue
Block a user