Skip to content

[Native Crash] App crashes after repeated Start/Stop cycles (4~15 times) related to GetRenderEventFunc #29

Description

@Conghung43

First, thank you for this excellent library.

I am encountering a crash on Android when the UVC camera is started and stopped repeatedly (stress testing the lifecycle). After approximately 4-15 cycles of calling StartUVC and StopUVC, the application crashes.

I have extensively debugged the C# side to ensure:

Texture2D objects are properly Destroyed.

Render Coroutines are properly stopped.

Race conditions between Start and Stop in C# are handled.

Despite resolving managed memory leaks, the crash persists. It appears to be a native memory leak or thread synchronization issue within the unityuvcplugin, specifically related to GetRenderEventFunc and the handling of the render event loop when the plugin is toggled rapidly.

Steps to Reproduce:

Connect a UVC Camera.

Run a loop that calls StartUVC (which calls native Start) and then StopUVC (which calls native Stop) repeatedly.

Observe the crash after roughly 4-15 iterations.

Reproduction Code (Conceptual):

C#

// Executing this rapid toggle causes the native plugin to crash
public void StressTest()
{
StartCoroutine(TestLoop());
}

IEnumerator TestLoop()
{
for(int i = 0; i < 20; i++)
{
Debug.Log($"Cycle {i}: Start");
manager.StartUVC();
yield return new WaitForSeconds(5f); // Even with delay, it eventually crashes

    Debug.Log($"Cycle {i}: Stop");
    manager.StopUVC();
    yield return new WaitForSeconds(5f);
}

}
Observed Behavior: The app crashes entirely (Force Close).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions