Skip to content

Conversation

@asabri97
Copy link
Collaborator

@asabri97 asabri97 commented Jan 6, 2026

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Fixes an Android SIGSEGV crash caused by a teardown race condition when YOLOView is disposed during active TensorFlow Lite inference. 🛠️

📊 Key Changes

  • Added a @Volatile isStopped flag in android/src/main/kotlin/com/ultralytics/yolo/YOLOView.kt to guard onFrame against running after stop() begins 🧵
  • Implemented multiple early-exit checks in onFrame (pre-processing, post-bitmap conversion, and pre-inference) to avoid accessing released resources 🛑
  • Set isStopped = true at the start of stop() and reset it in startCamera() to support safe restarts 🔄
  • Wrapped predictor close in a try/catch to prevent teardown exceptions from cascading 🧯
  • Bumped plugin version to 0.1.44 and documented the fix in CHANGELOG.md 📝

🎯 Purpose & Impact

  • Prevents native crashes when users navigate away or dispose YOLOView while inference is still running on Android 📱
  • Improves stability for camera/inference lifecycle transitions (stop/restart) with minimal functional changes ✅
  • Reduces risk of accessing a closed TFLite interpreter due to concurrent frame callbacks 🧠

@asabri97 asabri97 linked an issue Jan 6, 2026 that may be closed by this pull request
2 tasks
@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working fixed Bug has been resolved labels Jan 6, 2026
@UltralyticsAssistant
Copy link
Member

👋 Hello @asabri97, thank you for submitting a ultralytics/yolo-flutter-app 🚀 PR! This is an automated message to help streamline review—an Ultralytics engineer will assist shortly. 🧩

-✅ Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
-✅ Synchronize with Source: Confirm your PR is synchronized with the ultralytics/yolo-flutter-app main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
-✅ Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
-✅ Update Documentation: Update the relevant documentation for any new or modified features.
-✅ Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
-✅ Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
-✅ Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

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

🔍 PR Review

Made with ❤️ by Ultralytics Actions

Good targeted mitigation with @Volatile isStopped + early exits to avoid accessing cleared camera resources during teardown, and the version/changelog updates look consistent. One remaining risk: stop() can still close the predictor while an inference is already running; adding explicit coordination (lock/await termination/serialize close with inference) would make the SIGSEGV fix robust.

💬 Posted 1 inline comment

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixed Bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android App Crash : when the view is destroyed while inference is running.

4 participants