Skip to content

Add thread safety and lifecycle for native pointers#70

Open
edde746 wants to merge 2 commits intopeerless2012:masterfrom
edde746:fix/thread-safety
Open

Add thread safety and lifecycle for native pointers#70
edde746 wants to merge 2 commits intopeerless2012:masterfrom
edde746:fix/thread-safety

Conversation

@edde746
Copy link
Contributor

@edde746 edde746 commented Mar 20, 2026

Summary

  • Add null guards to all JNI functions that dereference native pointers (prevents crash when pointer is 0)
  • Add explicit release() methods to Ass, AssTrack, and AssRender (replaces GC-only finalize() cleanup)
  • Add ReentrantLock in AssRender to synchronize renderFrame, setTrack, and release
  • Synchronize AssHandler.readTrackDialogue() with the render lock to prevent concurrent ass_process_chunk / ass_render_frame on the same track
  • Add AssHandler.release() for explicit native resource cleanup

Context

Google Play Console reports native crashes in libass.so (ass_parse_tags, ass_render_frame) caused by concurrent thread access to ASS_Track* and null/freed native pointers.

@moi15moi
Copy link
Contributor

I believe to be properly thread safe, any call to libass should use the same mutex.

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