Skip to content

Prevent silent crashes and validate model files#11

Merged
ivan-digital merged 1 commit intomainfrom
fix/crash-prevention
Apr 7, 2026
Merged

Prevent silent crashes and validate model files#11
ivan-digital merged 1 commit intomainfrom
fix/crash-prevention

Conversation

@ivan-digital
Copy link
Copy Markdown
Contributor

Summary

  • Throw clear errors instead of failing silently when native pipeline creation fails
  • Validate model files on startup: corrupt/incomplete files are auto-deleted and redownloaded
  • Catch all throwables (including UnsatisfiedLinkError) in demo app

Changes

  • SpeechPipeline.kt: throw if nativeCreate returns 0 (was silent no-op)
  • jni_bridge.cpp: throw Java RuntimeException on native model load failure
  • MainActivity.kt: catch Throwable instead of Exception
  • ModelManager.kt: validate file size + ONNX magic bytes, auto-redownload if invalid

Test plan

  • Build passes
  • 15/15 unit tests pass
  • Test with corrupt model file (rename a valid .onnx to force redownload)

- SpeechPipeline: throw if nativeCreate returns 0 (was silent no-op)
- jni_bridge: throw Java RuntimeException on native model load failure
  (was logging + returning 0 silently)
- MainActivity: catch Throwable (including UnsatisfiedLinkError) not
  just Exception
- ModelManager: validate downloaded models (size check + ONNX magic
  bytes), auto-delete and redownload corrupt files
@ivan-digital ivan-digital merged commit 1417992 into main Apr 7, 2026
@ivan-digital ivan-digital deleted the fix/crash-prevention branch April 7, 2026 20:57
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.

1 participant