Skip to content

chore: Tối ưu script build DMG giúp mount nhanh hơn và không bị treo#9

Closed
meichengg wants to merge 11 commits intottdatt:mainfrom
meichengg:chore/optimize-dmg
Closed

chore: Tối ưu script build DMG giúp mount nhanh hơn và không bị treo#9
meichengg wants to merge 11 commits intottdatt:mainfrom
meichengg:chore/optimize-dmg

Conversation

@meichengg
Copy link
Copy Markdown

Chào bạn 👋

Mình nhận thấy file DMG được build ra mỗi khi mở và kéo thả app vào thư mục Applications hay bị delay/treo nhẹ một lúc. Nguyên nhân là do:

  1. hdiutil create -srcfolder mặc định tạo ra DMG format APFS (ở macOS bản mới), format này mount disk image khá chậm so với HFS+.
  2. File DMG đó không được code sign (dù app bên trong có sign rồi), nên macOS Gatekeeper phải quét sâu toàn bộ ruột DMG.

Mình xin phép gửi PR tối ưu lại script build_dmg.sh:

  • Mình đổi format DMG về HFS+ cho nhẹ và nhanh.
  • Chia quá trình tạo từ 1 bước lười (tạo trực tiếp) thành 2 bước chuẩn: Tạo file nháp Read/Write (UDRW) -> Convert sang Compressed (UDZO), giúp layout file system ổn định hơn.
  • Thêm cờ --sign cho file .dmg để macOS Gatekeeper vượt rào xác thực siêu tốc khi người dùng mở DMG lên.

Cảm ơn bạn nhiều! 🚀

@ttdatt
Copy link
Copy Markdown
Owner

ttdatt commented Mar 5, 2026

Cảm ơn bạn, mình dùng AI review, thì có 1 vài nhận xét sau. Bạn xem thử nha

• The change introduces a silent-failure path for DMG signing under --sign, which can cause the script to report success while producing an
unsigned artifact. That behavior is a functional regression for signed release workflows.

Findings

  • Medium Silent signing failure when --sign is enabled: codesign is now explicitly ignored with || true, so the script exits successfully even if DMG signing fails (ViType-macos/scripts/build_dmg.sh:337).
    • Repro conditions: expired/missing cert, keychain access denied, wrong identity, or signing service issues.
    • Impact: release process can report success while shipping an unsigned DMG (contrary to --sign intent), making failures hard to detect.
    • Action: remove || true (preferred), or emit a strong warning and fail when --sign is set.
  • Medium (outside diff, related prerequisite) Release CI does not use this script and still builds DMG with the old one-step flow, so this optimization/signing behavior is not applied to published artifacts (.github/workflows/build.yml:204, .github/workflows/build.yml:206, .github/workflows/build.yml:207, .github/workflows/build.yml:229).
    • Repro conditions: any GitHub tag release path.
    • Impact: branch change affects local/manual packaging only; official releases remain on old behavior, which can create expectation drift.
    • Action: either call ViType-macos/scripts/build_dmg.sh from CI or replicate the same two-step/create-convert + signing policy in workflow.
  • Low Temporary DMG cleanup is not guaranteed on failure: TEMP_DMG is removed only after successful convert (ViType-macos/scripts/build_dmg.sh:313, ViType-macos/scripts/build_dmg.sh:332).
    • Repro conditions: hdiutil convert fails/interrupted run.
    • Impact: stale temp_*.dmg files accumulate in dist/, potentially confusing subsequent manual release steps.
    • Action: include TEMP_DMG in trap cleanup EXIT or add a dedicated trap for temp image cleanup.

eejay and others added 10 commits March 18, 2026 13:56
- Add vitype_engine_get_buffer_len() FFI to query current composed word length
- Intercept Ctrl+W/Ctrl+Backspace: send correct backspace count instead of
  relying on terminal's native word-delete (which sees raw bytes, not composed text)
- Remove hardcoded TUI app list (claude, aider, codex) — replaced with universal
  detection: any non-shell leaf process in terminal tree is treated as TUI
- Reduce injection delays ~20% across all methods for smoother typing
- Add dev CI workflow for unsigned test builds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Xcode project has its own copy of vitype_core.h under
ViType-macos/ViType/ which takes precedence over the canonical
ViType-core/include/ header. The new function declaration was
only added to the canonical copy, causing the build to fail with
"cannot find 'vitype_engine_get_buffer_len' in scope".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the backspace+retype architecture with Apple's official
Input Method Kit for flicker-free inline composition (marked text).

Key changes:
- New InputController.swift: IMKInputController subclass handling
  key events via client.setMarkedText() / client.insertText()
- New main.swift: IMKServer entry point replacing @main SwiftUI
- New Info.plist: IMK configuration (connection name, controller
  class, input mode for Vietnamese/Telex)
- Rust core: added get_composed_text() FFI to return full buffer
  for marked text display
- Removed: CGEvent tap, CharacterInjector, backspace+retype logic,
  process tree TUI detection, injection delays
- Stubbed: MenuBarManager, WindowManager, Settings UI (IMK provides
  its own menu bar icon and right-click menu)
- Updated CI workflow: DMG now links to ~/Library/Input Methods/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root causes:
1. tsInputModeListKey was nested inside ComponentInputModeDict —
   macOS requires it at the top level of Info.plist
2. Missing tsInputModeIsVisibleKey — macOS hides input sources
   without this key set to true
3. Missing TISRegisterInputSource() call on first launch —
   required for macOS to discover and register the input method

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
macOS silently rejects TISRegisterInputSource() when the bundle
identifier doesn't contain 'inputmethod' in the path. Changed
from com.dat.ViType to com.dat.inputmethod.ViType.

Also simplified Info.plist: removed tsInputModeListKey (not needed
for simple single-mode input methods), added TISIntendedLanguage
at top level, added LSUIElement alongside LSBackgroundOnly — all
matching the pattern used by working IMK apps (XKey, XKeyIM) on
this machine.

Verified locally: TISRegisterInputSource now finds 1 source and
TISEnableInputSource succeeds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@meichengg meichengg closed this Apr 14, 2026
@meichengg meichengg deleted the chore/optimize-dmg branch April 14, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants