Skip to content

fix(whispercpp): ensure native binding compatibility on Windows - #807

Merged
haiphucnguyen merged 3 commits into
mainfrom
feature/fix-whisper-cpp-not-works-on-windows
Nov 6, 2026
Merged

haiphucnguyen merged 3 commits into
mainfrom
feature/fix-whisper-cpp-not-works-on-windows

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

⚠️ First-time contributor? This PR cannot be merged until you sign the CLA.
The CLA Assistant bot will post a comment below — reply to it with exactly:
I have read the CLA Document and I hereby sign the CLA
(Separate from this: all commits must also be signed off with git commit -s — see the Checklist.)

Summary

  • Replace host-dependent C_LONG mapping with JAVA_LONG to prevent ClassCastException on Windows
  • Update binding generation script to automatically patch C_LONG for LLP64 architectures
  • Add layout and integration tests to verify whisper bindings across platforms

Related Issue(s)

#806

Type of Change

  • [ X] 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactor (no functional change)
  • 🧪 Tests
  • 🔧 Chore / tooling / CI

What Changed & Why

How to Test

./gradlew test

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING guide
  • I signed the CLA (first-time contributors — reply to the CLA Assistant bot comment)
  • My branch is up to date with main
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

Additional Notes

- Replace host-dependent C_LONG mapping with JAVA_LONG to prevent ClassCastException on Windows
- Update binding generation script to automatically patch C_LONG for LLP64 architectures
- Add layout and integration tests to verify whisper bindings across platforms
Copilot AI lite review requested due to automatic review settings November 6, 2026 04:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical native-memory layout bug can byte-swap non-zero size values on little-endian platforms, while the integration test can silently skip the only end-to-end regression check when model downloads fail.

2 open issues
What changed in this PR

This pull request fixes Windows LLP64 compatibility for generated whisper.cpp bindings and adds cross-platform regression coverage.

Changes:

  • Map size_t-backed fields to a portable 8-byte layout and update the generation script.
  • Add binding layout and native integration tests.
  • Expand shared CI coverage to macOS and add required test fixtures.
  • Use centralized application colors in the whisper model download UI.
File Summary
desktop-shared/​src/​test/​kotlin/​io/​askimo/​ui/​voice/​whispercpp/​WhisperBindingsLayoutTest.kt Adds regression coverage for binding initialization, field size, and alignment.
desktop-shared/​src/​test/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperCppFfmSpeechToTextServiceIntegrationTest.kt Adds end-to-end native transcription coverage; model download failures are currently caught and may silently skip the test.
desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​voice/​impl/​whispercpp/​WhisperModelDownloadSection.kt Migrates card styling to centralized application color tokens.
desktop-shared/​src/​main/​java/​io/​askimo/​ui/​voice/​whispercpp/​whisper_h$shared.java Changes the generated C_LONG mapping to an 8-byte layout; the layout must also use native byte order for native struct compatibility.
desktop-shared/​scripts/​generate-whisper-bindings.sh Automates the generated binding patch; the resulting 8-byte layout must preserve native byte order.
desktop-shared/​build.gradle.kts Adds shared test-fixture support for the new tests.
.github/​workflows/​shared-tests.yml Adds macOS to the shared test matrix.

Review effort: Lite

Comment on lines +52 to +58
modelPath = try {
downloadModelIfMissing()
} catch (e: Exception) {
null.also {
println("Skipping ${javaClass.simpleName}: could not download whisper model (${e.message})")
}
}
@haiphucnguyen
haiphucnguyen merged commit 06ab473 into main Nov 6, 2026
13 of 14 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/fix-whisper-cpp-not-works-on-windows branch November 6, 2026 07:39
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