From d0187695581fa3a8fe5c3cfa8a1bc6337425f5f6 Mon Sep 17 00:00:00 2001 From: mac Date: Fri, 6 Nov 2026 17:07:18 +0800 Subject: [PATCH] fix: capture before symbolication and close resident app during upgrades --- Packaging/build_pkg.py | 38 +++++++++++++- research/CloudDiagnostics1.18.0.md | 4 ++ verification/DeliveryCandidate104.json | 69 +++++++++++++++++++++++++ verification/Diagnostics1.18.0.json | 10 +++- 大鱼调色/Plugin/Info.plist | 2 +- 大鱼调色/Shared/DYBetaDiagnostics.mm | 12 ++++- 大鱼调色/Wrapper Application/Info.plist | 2 +- 7 files changed, 130 insertions(+), 7 deletions(-) create mode 100644 verification/DeliveryCandidate104.json diff --git a/Packaging/build_pkg.py b/Packaging/build_pkg.py index ca5b8ce..a2afa17 100644 --- a/Packaging/build_pkg.py +++ b/Packaging/build_pkg.py @@ -11,6 +11,7 @@ import shutil import stat import subprocess import tempfile +import xml.etree.ElementTree as ET import sys ROOT = Path(__file__).resolve().parent.parent @@ -57,6 +58,37 @@ def check_package_bundle_access(package): return len(entries) +def prepare_resident_entry(skill, destination): + """Reuse Forge core; add our resident wrapper to its normal-quit checks.""" + runner = skill / "package_fxplug.py" + entry = skill / "PackageFxPlug.swift" + source = entry.read_text() + anchor = " var hosts = ApplicationToClose.presets\n" + assert source.count(anchor) == 1, "PKG 工坊入口变化,须重新核对常驻 APP 退出规则" + replacement = anchor + """ for item in items where item.kind == .fxPlug { + hosts.append(try ApplicationToClose.read(URL(fileURLWithPath: item.sourcePath))) + } +""" + destination.mkdir() + shutil.copy2(runner, destination / runner.name) + (destination / entry.name).write_text(source.replace(anchor, replacement)) + return dict(upstreamEntrySHA256=hashlib.sha256(entry.read_bytes()).hexdigest(), + adaptedEntrySHA256=hashlib.sha256((destination / entry.name).read_bytes()).hexdigest(), + requiredApplication="com.dayu.color") + + +def check_resident_close(package): + with tempfile.TemporaryDirectory(dir=CACHE) as scratch: + expanded = Path(scratch) / "expanded" + run("pkgutil", "--expand", str(package), str(expanded)) + distribution = ET.parse(expanded / "Distribution") + identifiers = [x.attrib.get("id") for x in distribution.findall(".//must-close/app")] + assert "com.dayu.color" in identifiers, "安装器必须正常退出常驻主 APP" + preinstalls = list(expanded.glob("*.pkg/Scripts/preinstall")) + assert preinstalls and all("'com.dayu.color'" in p.read_text() for p in preinstalls) + return dict(identifiers=identifiers, preinstallGuardCount=len(preinstalls), normalQuit=True) + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--pkg-forge-repo", type=Path, @@ -116,7 +148,9 @@ def main(): license="", conclusion="大鱼调色已安装。主 APP 自动注册插件,成功后保持运行。关闭窗口仍在后台收集已开启的诊断;菜单栏可重新打开或退出。请重开宿主并实际检查效果。")) manifest_path = CACHE / "dayu-color-package-manifest.json" manifest_path.write_text(json.dumps(manifest, ensure_ascii=False, indent=2) + "\n") - command = ["/usr/bin/python3", str(skill / "package_fxplug.py"), "--repo", str(forge), "--manifest", str(manifest_path)] + adapter = stage / "forge-entry" + adapter_record = prepare_resident_entry(skill, adapter) + command = ["/usr/bin/python3", str(adapter / "package_fxplug.py"), "--repo", str(forge), "--manifest", str(manifest_path)] subprocess.run(command + ["--check"], check=True) if args.prepare_only: print("清单:" + str(manifest_path)) @@ -127,6 +161,7 @@ def main(): subprocess.run(command, stdout=log, stderr=subprocess.STDOUT, check=True) package = args.output_dir / ("大鱼调色-" + version + ".pkg") verified_payload_entries = check_package_bundle_access(package) + resident_close = check_resident_close(package) report_path = ROOT / "verification/Package.json" subprocess.run(["/usr/bin/python3", str(skill / "verify_fxplug_package.py"), "--manifest", str(manifest_path), "--package", str(package), "--report", str(report_path)], check=True) @@ -138,6 +173,7 @@ def main(): report = json.loads(report_path.read_text()) report.update(notarization=job, appCompiledSource=delivery["sourceCommit"], appBuild=info["CFBundleVersion"], packageBuilderRemote="https://dayu.media/git/dayu/pkg-forge.git", + residentAppClosing=resident_close, packageEntryAdaptation=adapter_record, packageBuilderCommit=run("git", "rev-parse", "HEAD", cwd=forge), templateSHA256=hashes, payloadBundleAccess=dict(entries=verified_payload_entries, scope="Read/traverse modes for installer-owned app entries, from the package BOM"), installedAppHostAcceptance=delivery.get("hostVerification", "verification/HostLUTLoading.json"), diff --git a/research/CloudDiagnostics1.18.0.md b/research/CloudDiagnostics1.18.0.md index f3088fa..20757fe 100644 --- a/research/CloudDiagnostics1.18.0.md +++ b/research/CloudDiagnostics1.18.0.md @@ -20,3 +20,7 @@ 验证与交付结果待实现后追加。卡顿具体根因和 dyld 历史报告仍待新版本现场数据。 数据结构依据:[Apple IPS JSON 说明](https://developer.apple.com/documentation/xcode/interpreting-the-json-format-of-a-crash-report);运行循环依据:[CFRunLoop](https://developer.apple.com/documentation/corefoundation/cfrunloop)。 + +## 正式路径候选 104 的验收修正 + +FCP 12.4 加载、播放和阶段汇总上报通过。受控主线程暂停 12 秒时,采样以 timeout_or_disabled 送达,因此候选未发布。移除 sample 的 -mayDie(避免采样前预读符号),后台符号处理上限改为 30 秒;采集本身仍为 1 秒/10 ms 间隔,保留限频、关闭诊断取消及临时文件清理。后续以 105 正式路径再次验证实际调用栈。 diff --git a/verification/DeliveryCandidate104.json b/verification/DeliveryCandidate104.json new file mode 100644 index 0000000..c0d0f11 --- /dev/null +++ b/verification/DeliveryCandidate104.json @@ -0,0 +1,69 @@ +{ + "status": "installed-awaiting-host-verification", + "path": "/Library/Plug-Ins/FxPlug/大鱼调色.app", + "bundleID": "com.dayu.color", + "version": "1.18.0", + "build": "104", + "team": "B3W25FX5H5", + "notaryID": "d766ba9e-dcb5-462a-9497-83505e7dd239", + "notaryStatus": "Accepted", + "gatekeeper": "/Library/Plug-Ins/FxPlug/大鱼调色.app: accepted\nsource=Notarized Developer ID", + "sourceCommit": "e26a7c68e46bbd3f65f6052056d25a12f154123e", + "templatePath": "/Users/mac/Movies/Motion Templates.localized/Effects.localized/大鱼调色/大鱼调色/大鱼调色.moef", + "templateSHA256": "eaf60224f8d970f8841a03fe0325adc4af73d1c017375b020bcc0e256f0cd803", + "installedTemplateSHA256": { + "大鱼调色/大鱼调色.moef": "eaf60224f8d970f8841a03fe0325adc4af73d1c017375b020bcc0e256f0cd803", + "大鱼调色/large.png": "ab12611e8801cff86332ccc505a4cffa0c1120541c2efb9bb9908be2c9fe631a", + "大鱼调色/small.png": "41fec3138aee904fc39d6982e6fde809243ffec55298dbfe966f4f48d89caf8a", + "一级调色/一级调色.moef": "50e772b3670563ddce99fa2de63d87e5a14c81a8b7e37f15be32836c59ddafcb", + "一级调色/large.png": "b9b990a46f3fd9b6974a1aba1a3e9bff11a287fd1615d4cd0f9e7393c302631b", + "一级调色/small.png": "77b36c042fb82219651e5bd22c1057b644c06a528a8962d4afecdcb8cab52635", + "蜘蛛盘校色仪/蜘蛛盘校色仪.moef": "3c2af55314cdc4457bb3300138caa4ed87b5e6d9ec8dc2d2e3ba208bbacfd1a8", + "蜘蛛盘校色仪/large.png": "52de21d5fc598fda331cd472b937cf4aaf69a09c80d49e7b168ac7804e9cd040", + "蜘蛛盘校色仪/small.png": "ea9b69d12948c5cd5f6acd9d000822d9fff6df3beec9dd278077a8ab66d455cd", + "基础调整/基础调整.moef": "4a6b336349974fb0395d5218aeb501095eab7d501236fd238f9916cbf2071a12", + "基础调整/large.png": "a25e2b5ed50628ebe77220719528d14f21c25b5eecf37a5d60f211d2179ece43", + "基础调整/small.png": "3da91ae3461b882f5e1a557b4191d9aedaa6d329da70999eb7f26cbfb63a057f", + "肤色保护/肤色保护.moef": "83990f9e58c8ce1a59e4e52c597bd16831af94c3be679c53e9283fb04dd42cef", + "肤色保护/large.png": "f124e8f3d93c2be76ba26ba06d8b9c0b42e2c10dcb6300ae6ee7b7d7c7eb3025", + "肤色保护/small.png": "51fe525e67903101920a994d3540f368780d3aa9c0e54ebdb847871c82d81562", + "风格 LUT/风格 LUT.moef": "d424258d579c049df95ce361cee5373b7dc7d5a4f21cff5b1dd24adcdbc19942", + "风格 LUT/large.png": "a9a4b48885752282535ec3ec2ffbe19bcd27af7132337e4a4ad3d104a2082692", + "风格 LUT/small.png": "9ae76ba957b1e94a5a03a600140f59e98861917d13da9124082810c509400e36", + "HSL/HSL.moef": "baf84ec3b719c3a369ef0760713ba44b203bbfd0821c7a8d68919fef57d58fda", + "HSL/large.png": "eaa2e7b025dc59416fddb8de8b9c56f0a7d34ba70facd7aa45cfb84660f7da78", + "HSL/small.png": "3a54428bc6821e75935aa1be0f149aac6e6ce05fcc059b7f0e90ceef9a41981e", + "曲线/曲线.moef": "b2737c1b39fa039ee7876f3b473943168a15da65459b00802262a931feca3674", + "曲线/large.png": "273899eb6aa60fc0f7c8d41cc0e1f5a15b4c88a8803c00020a085ea874160870", + "曲线/small.png": "c17a2343b076650344b1c53ce92acf32f7696d66e32bda2d156996d4e3b834f5", + "颜色分级/颜色分级.moef": "9fe0319d878b8885d62e199bdea67d804e76f14104bcd233e33be22d60d1ad13", + "颜色分级/large.png": "f9afe6c3a76080a2a7c7ea98f24e62a74ab2e6fd8b4ad16ba9eb6065fef5d2ed", + "颜色分级/small.png": "9e9d7759f829d25a01a77422c989949b02ad34de81013f6b91505c4a3d1397e9", + "三原色/三原色.moef": "80894559be59396d6e06adc8d3343339cbf76f56bed12797446cbb568d6e10de", + "三原色/large.png": "bf7bfc893e294fc38c0f97e5594b6ba6e5c7126b9aae643754c89647e8bd5a1f", + "三原色/small.png": "2e28988e6bae0503edadef22cf7793ce51a1b8e5930623b2eff3c01212e57ee8", + "色阶/色阶.moef": "885c51e81f270078b6c05978a98e7d55ccafc7cd41035b0adbda068cb7149f2d", + "色阶/large.png": "fcea12f4367039ea1512d2e23d51b9ca5198172dc5b10a1ff94a828fe94f4802", + "色阶/small.png": "41cd1a9c4d3b68972181534abe0e91bdb9e01ef5559b6b1f7ef6bf305f450a76", + "黑白混色/黑白混色.moef": "6a7de91a44cd22aa5689c9aad725dccc7e4a29b6dd4e69a4158da7d02f7e559b", + "黑白混色/large.png": "6df07fb223ab43b2b5b6115bef4a1a97eed5cbeb6afab84e005c3a2bdfe01979", + "黑白混色/small.png": "5382be0d29b4a195b8639b3c325f80e9b8cecaa9c12837ab5cf57b6ea877ecbc", + "色彩平衡/色彩平衡.moef": "175ed9f890adf13e712dec264068fffde11accf6dc2e33c3bb278c4438f68362", + "色彩平衡/large.png": "fa2ce9071dee52d7ab9dc7cf6020f8679df3af707663c9a57a28fcde73e6801e", + "色彩平衡/small.png": "12a72a9f26e6ee41613b16ed2402f94a04837e55895addc8f5c25137ad7feaa6", + "通道混合器/通道混合器.moef": "06f497fffbcee034cfbf21e7f39a4b10e41ad49cafd0476f4825903e9169521d", + "通道混合器/large.png": "5ae9d2683450a3a515822520911885a774e202aa924465602f7369a1e67c0c4c", + "通道混合器/small.png": "23bfafb79287855e037f98f0ab5cee10914384824b1a65f0247cad2dd239ef1c", + "胶片模拟/胶片模拟.moef": "528835a129e158c9edf2b48d4a9521b2b9a40e845f04160eecd56e125473bbde", + "胶片模拟/large.png": "d36a794f9640874f6ad7f3523b9eac92ba7c6ef8fa7b63c4594fc68e87c2eee7", + "胶片模拟/small.png": "f125deaf0c8d55ecc04e555cfb133c40ff3703f34a663548c6b38b3196780eb1", + "镜头畸变修复/镜头畸变修复.moef": "0a75525f6e2203527f20a2945aac1a262aa2db57683065ab0ca793da7f5ecd0a", + "镜头畸变修复/large.png": "a00136fb9276c41518ba6096314fb6772ad1dc9be4f4d766409239fa923cfcd1", + "镜头畸变修复/small.png": "1b2480cfa33e1ab54a1ffcd81d9496aac1354b0d2974d6616fe7128965c2ede3", + "CST 色彩空间转换/CST 色彩空间转换.moef": "1399d6906748b206b2673a1d8460f83d9ddda07722d2214d85a9909f24171c17", + "CST 色彩空间转换/large.png": "816db272970491181aca4b872f09ca1900ebf0e7f21fee5bd6e2b4daedea5306", + "CST 色彩空间转换/small.png": "677353684eeaa1986bd21580eb0f2dcf4486f8cfba3985686c2ecb67afed5dbc" + }, + "shaderSHA256": "443ef7e178a5bbd6418a4d2eaac5d42f023f1a6a0a5c4ddd54c7c831af50eb6a", + "previousInstallBackup": "/Library/Plug-Ins/FxPlug/.dayu-color-previous-45dca8475efb4d6cb133b14d45d8372b.app" +} diff --git a/verification/Diagnostics1.18.0.json b/verification/Diagnostics1.18.0.json index f7da2b8..0e26dba 100644 --- a/verification/Diagnostics1.18.0.json +++ b/verification/Diagnostics1.18.0.json @@ -1,6 +1,6 @@ { "version": "1.18.0", - "build": 104, + "build": 105, "offlineClientChecks": 75, "backendContractChecks": 27, "appSyntax": "passed", @@ -13,5 +13,11 @@ "resource category without filename", "new server allowlist" ], - "formalRuntimeValidation": "pending" + "formalRuntimeValidation": "pending", + "candidate104": { + "hostPlayback": "passed", + "performanceSummary": "render/plugin_state/inspector_refresh reached cloud", + "hangProbe": "timeout_or_disabled; not accepted for release", + "correction": "sample before symbolication, 30-second background deadline" + } } diff --git a/大鱼调色/Plugin/Info.plist b/大鱼调色/Plugin/Info.plist index 2d72628..2e1297b 100644 --- a/大鱼调色/Plugin/Info.plist +++ b/大鱼调色/Plugin/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.18.0 CFBundleVersion - 104 + 105 NSHumanReadableCopyright PlugInKit diff --git a/大鱼调色/Shared/DYBetaDiagnostics.mm b/大鱼调色/Shared/DYBetaDiagnostics.mm index 5d0257c..19e24bf 100644 --- a/大鱼调色/Shared/DYBetaDiagnostics.mm +++ b/大鱼调色/Shared/DYBetaDiagnostics.mm @@ -101,6 +101,13 @@ static NSString *sysctlString(const char *key) { NSUserDefaults *prefs=preferences();[prefs registerDefaults:@{@"betaDiagnosticsEnabled":@YES}];gEnabled.store([prefs boolForKey:@"betaDiagnosticsEnabled"]); folder=[[[NSFileManager.defaultManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask].firstObject URLByAppendingPathComponent:@"com.dayu.color/Beta" isDirectory:YES]retain]; [NSFileManager.defaultManager createDirectoryAtURL:folder withIntermediateDirectories:YES attributes:@{NSFilePosixPermissions:@0700} error:nil]; + // A process can exit while the independent sampler is writing. Only remove our stale samples. + if([source isEqual:@"app"])for(NSURL *file in [NSFileManager.defaultManager contentsOfDirectoryAtURL:folder includingPropertiesForKeys:@[NSURLContentModificationDateKey] options:0 error:nil]) { + NSString *name=file.lastPathComponent; + if(![name hasPrefix:@"sample-"]||![[[NSUUID alloc]initWithUUIDString:[name substringFromIndex:7]]autorelease])continue; + NSDate *date=nil;[file getResourceValue:&date forKey:NSURLContentModificationDateKey error:nil]; + if(date&&date.timeIntervalSinceNow< -300)[NSFileManager.defaultManager removeItemAtURL:file error:nil]; + } // O_EXCL gives the APP and XPC one random installation ID without hardware UUIDs. NSURL *identity=[folder URLByAppendingPathComponent:@"installation.txt"]; NSString *newID=NSUUID.UUID.UUIDString.lowercaseString; @@ -210,11 +217,12 @@ static NSString *sysctlString(const char *key) { dispatch_async(evidenceQueue,^{@autoreleasepool{ NSURL *output=[self->folder URLByAppendingPathComponent:[@"sample-" stringByAppendingString:NSUUID.UUID.UUIDString]]; NSTask *task=[[[NSTask alloc]init]autorelease];task.executableURL=[NSURL fileURLWithPath:@"/usr/bin/sample"]; - task.arguments=@[[@(getpid())stringValue],@"1",@"10",@"-mayDie",@"-file",output.path]; + // Sample first, then symbolize; -mayDie preloads symbols and can miss a short hang. + task.arguments=@[[@(getpid())stringValue],@"1",@"10",@"-file",output.path]; task.standardOutput=[NSFileHandle fileHandleWithNullDevice];task.standardError=[NSFileHandle fileHandleWithNullDevice]; NSString *result=@"unavailable",*frames=@"";NSError *error=nil; if(gEnabled.load()&&[task launchAndReturnError:&error]) { - double deadline=NSProcessInfo.processInfo.systemUptime+8; + double deadline=NSProcessInfo.processInfo.systemUptime+30; while(task.running&&gEnabled.load()&&NSProcessInfo.processInfo.systemUptimeCFBundleShortVersionString 1.18.0 CFBundleVersion - 104 + 105 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright