Opened 12 years ago

Closed 10 years ago

#1571 closed defect (wontfix)

Deadlock when closing the video port on Mac OS X

Reported by: bennylp Owned by: nanang
Priority: normal Milestone: release-2.2.1
Component: pjmedia Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no


A deadlock may occur when the main thread is stopping a video port (e.g. stopping video preview) while the video port needs to perform an operation (e.g. drawing a picture).

In general, application may also get stuck if the main thread is blocked for a long time.

This only happens on Mac OS X, because with Cocoa all GUI operations need to be performed by the main thread, hence SDL operations are posted to the main thread. Unfortunately in this case, the main thread is blocked, waiting for the worker thread to complete, hence it's not able to process the operation that the worker thread is performing.

Sample stack trace is below:

Main thread:
1	pthread_join
2	pj_thread_join
3	pjmedia_clock_stop
4	pjmedia_vid_port_stop
5	free_vid_win
6	pjsua_vid_preview_stop

SDL worker thread (stack trace):
0	__psynch_cvwait
1	_pthread_cond_wait
2	-[NSCondition wait]
3	-[NSObject(NSThreadPerformAdditions)
4	-[NSObject(NSThreadPerformAdditions)
5	job_queue_post_job
6	sdl_stream_put_frame
7	vid_pasv_port_put_frame
8	tee_put_frame
9	enc_clock_cb
10	clock_thread

Thank you Denis Komadaric for the report.

Change History (2)

comment:1 Changed 10 years ago by bennylp

  • Milestone changed from release-2.2 to release-2.3

comment:2 Changed 10 years ago by ming

  • Resolution set to wontfix
  • Status changed from new to closed

To avoid deadlock with GUI thread, application needs to call PJSIP API, which can potentially block, from another thread.

Video Users Guide - Mac OS X

Note: See TracTickets for help on using tickets.