2020-10-09 SurfaceFlinger 卡死問題分析:

1:使用高的地圖進(jìn)行CarPlay 投屏?xí)r候,出現(xiàn)整個(gè)系統(tǒng)卡死.

2:log
"Binder:880_C" prio=5 tid=103 Native

? | group="main" sCount=1 dsCount=0 flags=1 obj=0x139c2cc0 self=0x7ce0ec5800

? | sysTid=2996 nice=-8 cgrp=default sched=0/0 handle=0x7cbc06d4f0

? | state=S schedstat=( 10540078349 11945271082 40545 ) utm=773 stm=280 core=0 HZ=100

? | stack=0x7cbbf73000-0x7cbbf75000 stackSize=1005KB

? | held mutexes=

? kernel: (couldn't read /proc/self/task/2996/stack)

? native: #00 pc 000000000006a824? /system/lib64/libc.so (__ioctl+4)

? native: #01 pc 00000000000240a0? /system/lib64/libc.so (ioctl+136)

? native: #02 pc 0000000000054b50? /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+260)

? native: #03 pc 00000000000558dc? /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel*, int*)+360)

? native: #04 pc 0000000000055614? /system/lib64/libbinder.so (android::IPCThreadState::transact(int, unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+224)

? native: #05 pc 000000000004c318? /system/lib64/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+72)

? native: #06 pc 000000000007d428? /system/lib64/libgui.so (???)

? native: #07 pc 000000000008cd90? /system/lib64/libgui.so (android::SurfaceComposerClient::createSurface(android::String8 const&, unsigned int, unsigned int, int, unsigned int, android::SurfaceControl*, unsigned int, unsigned int)+232)

? native: #08 pc 00000000000f89b8? /system/lib64/libandroid_runtime.so (???)

? native: #09 pc 0000000000d2ee38? /system/framework/arm64/boot-framework.oat (Java_android_view_SurfaceControl_nativeCreate__Landroid_view_SurfaceSession_2Ljava_lang_String_2IIIIJII+264)

? at android.view.SurfaceControl.nativeCreate(Native method)

? at android.view.SurfaceControl.<init>(SurfaceControl.java:341)

? at android.view.SurfaceControl.<init>(SurfaceControl.java:312)

? at com.android.server.wm.SurfaceControlWithBackground.<init>(SurfaceControlWithBackground.java:72)

? at com.android.server.wm.WindowSurfaceController.<init>(WindowSurfaceController.java:101)

? at com.android.server.wm.WindowStateAnimator.createSurfaceLocked(WindowStateAnimator.java:698)

? at com.android.server.wm.WindowManagerService.createSurfaceControl(WindowManagerService.java:2355)

? at com.android.server.wm.WindowManagerService.relayoutWindow(WindowManagerService.java:2100)

? - locked <0x027b8624> (a com.android.server.wm.WindowHashMap)

? at com.android.server.wm.Session.relayout(Session.java:239)

? at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:286)

? at com.android.server.wm.Session.onTransact(Session.java:163)

? at android.os.Binder.execTransact(Binder.java:697)


從中可以看到 SystemService 在申請(qǐng)WindowHashMap Lock之后,? 遠(yuǎn)程調(diào)用surfaceflinger 創(chuàng)建一個(gè)新的Layer 的時(shí)候,一直沒有返回

3.我們看一下surfaceflinger的?? 線程情況:

"Binder:399_4" sysTid=1067

? #00 pc 000000000001d52c? /system/lib64/libc.so (syscall+28)

? #01 pc 00000000000676b8? /system/lib64/libc.so (pthread_cond_wait+96)

? #02 pc 000000000005ee48? /system/lib64/libgui.so (android::BufferQueueProducer::waitForFreeSlotThenRelock(android::BufferQueueProducer::FreeSlotCaller, int*) const+708)

? #03 pc 000000000005f160? /system/lib64/libgui.so (android::BufferQueueProducer::dequeueBuffer(int*, android::sp<android::Fence>*, unsigned int, unsigned int, int, unsigned long, unsigned long*, android::FrameEventHistoryDelta*)+424)

? #04 pc 0000000000074208? /system/lib64/libgui.so (android::BnGraphicBufferProducer::onTransact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+448)

? #05 pc 000000000004af20? /system/lib64/libbinder.so (android::BBinder::transact(unsigned int, android::Parcel const&, android::Parcel*, unsigned int)+136)

? #06 pc 0000000000055004? /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+528)

? #07 pc 0000000000054d44? /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+156)

? #08 pc 0000000000055394? /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+60)

? #09 pc 000000000007728c? /system/lib64/libbinder.so

? #10 pc 0000000000011478? /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+280)

? #11 pc 000000000006803c? /system/lib64/libc.so (__pthread_start(void*)+36)

? #12 pc 000000000001edfc? /system/lib64/libc.so (__start_thread+68)

可以看到? 其中 GraphicBuffer 已經(jīng)沒有可以使用的? INVALID_BUFFER_SLOT, 一直在在等待 hwc? 完成圖像的合成. 釋放信息buffer.(? zhijian CarPlay app? 沒有設(shè)置mDequeueTimeout ,? mMaxDequeuedBufferCount=16 )


4:SurfaceFlinger 的其他線程也在等待 HWC binder 執(zhí)行完成.

Cmd line: /system/bin/surfaceflinger

"surfaceflinger" sysTid=399

? #00 pc 0000000000015208? /system/lib64/libhwbinder.so (android::hardware::IPCThreadState::talkWithDriver(bool)+260)

? #01 pc 00000000000160ec? /system/lib64/libhwbinder.so (android::hardware::IPCThreadState::waitForResponse(android::hardware::Parcel*, int*)+360)

? #02 pc 0000000000015e18? /system/lib64/libhwbinder.so (android::hardware::IPCThreadState::transact(int, unsigned int, android::hardware::Parcel const&, android::hardware::Parcel*, unsigned int)+224)

? #03 pc 0000000000012858? /system/lib64/libhwbinder.so (android::hardware::BpHwBinder::transact(unsigned int, android::hardware::Parcel const&, android::hardware::Parcel*, unsigned int, std::__1::function<void (android::hardware::Parcel&)>)+72)

? #04 pc 0000000000038da4? /system/lib64/android.hardware.graphics.composer@2.1.so (android::hardware::graphics::composer::V2_1::BpHwComposerClient::_hidl_executeCommands(android::hardware::IInterface*, android::hardware::details::HidlInstrumentor*, unsigned int, android::hardware::hidl_vec<android::hardware::hidl_handle> const&, std::__1::function<void (android::hardware::graphics::composer::V2_1::Error, bool, unsigned int, android::hardware::hidl_vec<android::hardware::hidl_handle> const&)>)+372)

? #05 pc 0000000000039c98? /system/lib64/android.hardware.graphics.composer@2.1.so (android::hardware::graphics::composer::V2_1::BpHwComposerClient::executeCommands(unsigned int, android::hardware::hidl_vec<android::hardware::hidl_handle> const&, std::__1::function<void (android::hardware::graphics::composer::V2_1::Error, bool, unsigned int, android::hardware::hidl_vec<android::hardware::hidl_handle> const&)>)+148)

? #06 pc 00000000000895ac? /system/lib64/libsurfaceflinger.so

? #07 pc 000000000008a448? /system/lib64/libsurfaceflinger.so

? #08 pc 000000000009367c? /system/lib64/libsurfaceflinger.so

? #09 pc 00000000000bc854? /system/lib64/libsurfaceflinger.so

? #10 pc 000000000006a55c? /system/lib64/libsurfaceflinger.so

? #11 pc 00000000000a5f90? /system/lib64/libsurfaceflinger.so

? #12 pc 00000000000a4e8c? /system/lib64/libsurfaceflinger.so

? #13 pc 00000000000a4b30? /system/lib64/libsurfaceflinger.so

? #14 pc 0000000000015e04? /system/lib64/libutils.so (android::Looper::pollInner(int)+332)

? #15 pc 0000000000015c28? /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+108)

? #16 pc 00000000000818ec? /system/lib64/libsurfaceflinger.so

? #17 pc 00000000000a34e0? /system/lib64/libsurfaceflinger.so (android::SurfaceFlinger::run()+20)

? #18 pc 0000000000002e80? /system/bin/surfaceflinger

? #19 pc 00000000000a1fb8? /system/lib64/libc.so (__libc_init+88)

? #20 pc 0000000000002978? /system/bin/surfaceflinger


5:HWC 沒有打印線程情況,只能從GED log中分析:

09-10 13:01:41.703514 387 6848 D SkipV(3: do skip vali

09-10 13:01:41.703621? 387? 6848 D [HWC] (0) VAL list=2/max=12/fbt=0[-1,-1:-1,-1](OVL)/ui=1/mm=1/ovlp=4259840/fi=1/mir=-1?

09-10 13:01:41.703807? 387? 6848 D (0) SET job=0/max=12/fbt=0(OVL)/ui=1/mm=1/mir=-1/ult=0/flush=0/black=0/PF(fd=136, idx=72830, curr_pf_fd=136,132)?

09-10 13:01:41.703976? 387? 6848 D [TOL] [mm_ionImport] ion_fd(110) -> share_fd(142)?

09-10 13:01:41.703993? 387? 6848 D [BLT_ASYNC]SET(0,0)/rel=139/acq=-1/handle=0x7f84e9cee0/job=61360?

09-10 13:01:41.704117? 387? 6848 D [HWC] (0) (L3353) set s:PD=>displayPresent s:PD=>(L3268) set s:CSV=>(L3283) set s:VD=>(L1436) set s:P=>?

09-10 13:01:41.737992? 387? 6848 D [DEV] (0) DispSessionMode (DL) id:10000?

09-10 13:01:41.738001? 387? 6848 D [HWC] setBufFromSf 0:134,9d0a 0:12,9c70?

09-10 13:01:41.738066? 387? 6848 D SkipV(3: do skip vali?

09-10 13:01:41.738116? 387? 6848 D [HWC] (0) VAL list=2/max=12/fbt=0[-1,-1:-1,-1](OVL)/ui=1/mm=1/ovlp=4259840/fi=1/mir=-1?

09-10 13:01:41.738195? 387? 6848 D (0) SET job=0/max=12/fbt=0(OVL)/ui=1/mm=1/mir=-1/ult=0/flush=0/black=0/PF(fd=140, idx=72831, curr_pf_fd=140,136)?

09-10 13:01:41.738273? 387? 6848 D [TOL] [mm_ionImport] ion_fd(119) -> share_fd(146)?

09-10 13:01:41.738279? 387? 6848 D [BLT_ASYNC]SET(0,0)/rel=143/acq=-1/handle=0x7f84e9d0a0/job=61361?

09-10 13:01:41.738498? 387? 6848 W [JOB] (0) Jobs have piled up, wait for clearing!!?

09-10 13:01:41.738517? 387? 6848 D [WKR] Waiting for Dispatcher_0...?

09-10 13:01:41.838904? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=1/val=6)?

09-10 13:01:41.939377? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=3/val=6)?

09-10 13:01:42.039855? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=5/val=6)?

09-10 13:01:42.140239? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=7/val=6)?

09-10 13:01:42.240897? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=9/val=6)?

09-10 13:01:42.341493? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=11/val=6)?

09-10 13:01:42.441838? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=13/val=6)?

09-10 13:01:42.542413? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=15/val=6)?

09-10 13:01:42.642909? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=17/val=6)?

09-10 13:01:42.743223? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=19/val=6)?

09-10 13:01:42.793564? 387? 6848 E [WKR] Timed out waiting for Dispatcher_0 (cnt=20/val=6)?

09-10 13:01:42.843810? 387? 6848 W [WKR] Timed out waiting for Dispatcher_0 (cnt=21/val=6)

什么是Dispatcher 線程?

HWC 把需要執(zhí)行的動(dòng)作 以job的形式post 到Dispatcher 線程, 最終由Dispatcher 來執(zhí)行動(dòng)作.

從 log上看 Dispatcher 線程已經(jīng)卡死.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末剖张,一起剝皮案震驚了整個(gè)濱河市顽分,隨后出現(xiàn)的幾起案子驯耻,更是在濱河造成了極大的恐慌蚕苇,老刑警劉巖飒硅,帶你破解...
    沈念sama閱讀 217,542評(píng)論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件束析,死亡現(xiàn)場(chǎng)離奇詭異堡距,居然都是意外死亡趾断,警方通過查閱死者的電腦和手機(jī)绍申,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,822評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門噩咪,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人极阅,你說我怎么就攤上這事胃碾。” “怎么了筋搏?”我有些...
    開封第一講書人閱讀 163,912評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵仆百,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我奔脐,道長(zhǎng)俄周,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,449評(píng)論 1 293
  • 正文 為了忘掉前任帖族,我火速辦了婚禮栈源,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘竖般。我一直安慰自己甚垦,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,500評(píng)論 6 392
  • 文/花漫 我一把揭開白布涣雕。 她就那樣靜靜地躺著艰亮,像睡著了一般。 火紅的嫁衣襯著肌膚如雪挣郭。 梳的紋絲不亂的頭發(fā)上迄埃,一...
    開封第一講書人閱讀 51,370評(píng)論 1 302
  • 那天,我揣著相機(jī)與錄音兑障,去河邊找鬼侄非。 笑死,一個(gè)胖子當(dāng)著我的面吹牛流译,可吹牛的內(nèi)容都是我干的逞怨。 我是一名探鬼主播,決...
    沈念sama閱讀 40,193評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼福澡,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼叠赦!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起革砸,我...
    開封第一講書人閱讀 39,074評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤除秀,失蹤者是張志新(化名)和其女友劉穎糯累,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體册踩,經(jīng)...
    沈念sama閱讀 45,505評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡泳姐,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,722評(píng)論 3 335
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了棍好。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片仗岸。...
    茶點(diǎn)故事閱讀 39,841評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖借笙,靈堂內(nèi)的尸體忽然破棺而出扒怖,到底是詐尸還是另有隱情,我是刑警寧澤业稼,帶...
    沈念sama閱讀 35,569評(píng)論 5 345
  • 正文 年R本政府宣布盗痒,位于F島的核電站,受9級(jí)特大地震影響低散,放射性物質(zhì)發(fā)生泄漏俯邓。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,168評(píng)論 3 328
  • 文/蒙蒙 一熔号、第九天 我趴在偏房一處隱蔽的房頂上張望稽鞭。 院中可真熱鬧,春花似錦引镊、人聲如沸朦蕴。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,783評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽吩抓。三九已至,卻和暖如春赴恨,著一層夾襖步出監(jiān)牢的瞬間疹娶,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,918評(píng)論 1 269
  • 我被黑心中介騙來泰國打工伦连, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留雨饺,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,962評(píng)論 2 370
  • 正文 我出身青樓惑淳,卻偏偏與公主長(zhǎng)得像额港,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子汛聚,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,781評(píng)論 2 354