Why JSRunLoopTimerCallBack executes in the main thread?

Hi,all.

My application used the JavaScriptCore framework.

What I'm confused about is:

Instance of JSContext was created in the work queue, and there was no code that access JSCore in the main thread,but JSC::JSRunLoopTimer::Manager::timerDidFire executed in the main thread.

Sometimes,I got a dead-lock.



The call stack of the main thread:


#0 0x0000000194a4dc94 in __psynch_cvwait ()

#1 0x000000019496acf8 in _pthread_cond_wait$VARIANT$mp ()

#2 0x00000001a399595c in ***::ThreadCondition::timedWait(***::Mutex&, ***::WallTime) ()

#3 0x00000001a397b848 in ***::ParkingLot::parkConditionallyImpl(void const*, ***::ScopedLambda<bool ()> const&, ***::ScopedLambda<void ()> const&, ***::TimeWithDynamicClockType const&) ()

#4 0x00000001a396e6e4 in ***::LockAlgorithm<unsigned char, (unsigned char)1, (unsigned char)2, ***::EmptyLockHooks<unsigned char> >::lockSlow(***::Atomic<unsigned char>&) ()

#5 0x00000001a4379f68 in JSC::JSLock::lock(long) ()

#6 0x00000001a43a4b44 in JSC::JSRunLoopTimer::timerDidFire() ()

#7 0x00000001a43a47c8 in JSC::JSRunLoopTimer::Manager::timerDidFire() ()

#8 0x0000000194bd503c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()

#9 0x0000000194bd4d78 in __CFRunLoopDoTimer ()

#10 0x0000000194bd4448 in __CFRunLoopDoTimers ()

#11 0x0000000194bcf584 in __CFRunLoopRun ()

#12 0x0000000194bceadc in CFRunLoopRunSpecific ()

#13 0x0000000194f0e7f4 in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()




device:iPhone 6s

iOS:13.3

xcode:11.3



Thanks!

Replies

Instance of JSContext was created in the work queue

What do you mean by “work queue” in this context?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

ps DTS is closed 21 Dec through 1 Jan.