ANR of app caused by native mediaserver.docx

上传人:b****6 文档编号:8474112 上传时间:2023-01-31 格式:DOCX 页数:22 大小:28.61KB
下载 相关 举报
ANR of app caused by native mediaserver.docx_第1页
第1页 / 共22页
ANR of app caused by native mediaserver.docx_第2页
第2页 / 共22页
ANR of app caused by native mediaserver.docx_第3页
第3页 / 共22页
ANR of app caused by native mediaserver.docx_第4页
第4页 / 共22页
ANR of app caused by native mediaserver.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

ANR of app caused by native mediaserver.docx

《ANR of app caused by native mediaserver.docx》由会员分享,可在线阅读,更多相关《ANR of app caused by native mediaserver.docx(22页珍藏版)》请在冰豆网上搜索。

ANR of app caused by native mediaserver.docx

ANRofappcausedbynativemediaserver

ANRofappcausedbynativemediaserver

本文记述了由mediaserver引起的其它应用ANR的分析方法.因为android的pthread_mutex使用BITS_NORMAL类型futex实现,不能从futex本身和内核对象知道当前哪个进程拥有锁,所以针对mediaserver这种native应用,只能从线程组内各线程的调用栈来分析锁拥有线程链.

ForandroidJellyBeanrelease.

FromAndroidsystemlog

WARN[3078.755804](564:

631)BroadcastQueueTimeoutofbroadcastBroadcastRecord{438e0100com.android.server.WifiManager.action.START_SCAN}-receiver=android.app.LoadedApk$ReceiverDispatcher$InnerReceiver@429a7950,started60002msago

PROBABLECAUSEOFPROBLEM:

Timeout

Receiver:

android.app.LoadedApk$ReceiverDispatcher$InnerReceiver

....GeneratingDalvikbacktraces.Thismighttakesometime....

Receiver:

mightbepid630

Pid630(ServerThread)couldbeinterestingtoinvestigated

*****Dalvikstackforpid630*****

#0android.media.AudioService.handleDeviceConnection(AudioService.java:

3523)

#1android.media.AudioService.access$7100(AudioService.java:

110)

#2android.media.AudioService$AudioServiceBroadcastReceiver.onReceive(AudioService.java:

3725)

#3android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:

765)

#4android.os.Handler.handleCallback(Handler.java:

615)

#5android.os.Handler.dispatchMessage(Handler.java:

94)

#6android.os.Looper.loop(Looper.java:

256)

#7com.android.server.ServerThread.run(SystemServer.java:

278)

--Breakframe--

============================================================================

Thelogsays:

Receiverpid630hasnotresposedforthebroadcast.

Pid630needsinvestigation.

Dumpprocess630andusegdbtoanalyzeit.

ThreadServerThreadinformationandjavacallstacklistasfollows.threadlistlen=101

(mutexes:

tll=0tsl=0tscl=0ghl=0)

*1"android.server.ServerThread"prio=5tid=12MONITOR

|group="N/A"sCount=0dsCount=0obj=0x42755328self=0x5e0fc008

|sysTid=630nice=0sched=0/0cgrp=handle=0x5e0fc458

-waitingtolock<0x42bfe3a8>(aLjava/util/HashMap;)heldbytid=49(AudioService)

#0android.media.AudioService.handleDeviceConnection()

#1android.media.AudioService.access$7100()

#2android.media.AudioService$AudioServiceBroadcastReceiver.onReceive()

#3android.app.LoadedApk$ReceiverDispatcher$Args.run()

#4android.os.Handler.handleCallback()

#5android.os.Handler.dispatchMessage()

#6android.os.Looper.loop()

#7com.android.server.ServerThread.run()

#8---breakframe---

ServerThreadiswaitingforalockheldbytid=49(AudioService),thread61.

Investigatesourcecodeofthread61tofindoutthesynchronizedlock.

handleDeviceConnection()@AudioService.java

3521privatebooleanhandleDeviceConnection(booleanconnected,intdevice,Stringparams){

3522synchronized(mConnectedDevices){***************

3523booleanisConnected=(mConnectedDevices.containsKey(device)&&

3524(params.isEmpty()||mConnectedDevices.get(device).equals(params)));

3525

3526if(isConnected&&!

connected){

3527AudioSystem.setDeviceConnectionState(device,

3528AudioSystem.DEVICE_STATE_UNAVAILABLE,

3529mConnectedDevices.get(device));

3530mConnectedDevices.remove(device);

3531returntrue;

3532}elseif(!

isConnected&&connected){

3533AudioSystem.setDeviceConnectionState(device,

3534AudioSystem.DEVICE_STATE_AVAILABLE,

3535params);

3536mConnectedDevices.put(newInteger(device),params);

3537returntrue;

3538}

3539}

3540returnfalse;

3541}

ThreadAudioService'sjavacallstacklistsasfollows.

[Switchingtothread61(LWP805)]

#0__ioctl()atbionic/libc/arch-arm/syscalls/__ioctl.S:

10

10bionic/libc/arch-arm/syscalls/__ioctl.S:

Nosuchfileordirectory.

#0android.media.AudioSystem.setDeviceConnectionState()

#1android.media.AudioService.makeA2dpDeviceUnavailableNow()

#2android.media.AudioService.onSetA2dpConnectionState()

#3android.media.AudioService.access$6500()

#4android.media.AudioService$AudioHandler.handleMessage()

#5android.os.Handler.dispatchMessage()

#6android.os.Looper.loop()

#7android.media.AudioService$AudioSystemThread.run()

#8---breakframe---

ItcanbefoundthatthethreadisinAudioSystem:

:

setDeviceConnectionState()method,holdingthelockofmConnectedDevicesandwaitingbindercommunicationrespose.Therelatedsourcecode,

onSetA2dpConnectionState()@AudioService.java

3462privatevoidonSetA2dpConnectionState(BluetoothDevicebtDevice,intstate)

3463{

3464if(btDevice==null){

3465return;

3466}

3467Stringaddress=btDevice.getAddress();

3468if(!

BluetoothAdapter.checkBluetoothAddress(address)){

3469address="";

3470}

3471synchronized(mConnectedDevices){************

3472booleanisConnected=

3473(mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)&&

3474mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP).equals(address));

3475

3476if(isConnected&&state!

=BluetoothProfile.STATE_CONNECTED){

3477if(btDevice.isBluetoothDock()){

3478if(state==BluetoothProfile.STATE_DISCONNECTED){

3479//introductionofadelayfortransientdisconnectionsofdockswhen

3480//powerisrapidlyturnedoff/on,thismessagewillbecanceledif

3481//wereconnectthedockunderapresetdelay

3482makeA2dpDeviceUnavailableLater(address);

3483//thenexttimeisConnectedisevaluated,itwillbefalseforthedock

3484}

3485}else{

3486makeA2dpDeviceUnavailableNow(address);

3487}

3488synchronized(mCurAudioRoutes){

3489if(mCurAudioRoutes.mBluetoothName!

=null){

3490mCurAudioRoutes.mBluetoothName=null;

3491sendMsg(mAudioHandler,MSG_REPORT_NEW_ROUTES,

3492SENDMSG_NOOP,0,0,null,0);

3493}

3494}

3495}elseif(!

isConnected&&state==BluetoothProfile.STATE_CONNECTED){

3496if(btDevice.isBluetoothDock()){

3497//thiscouldbeareconnectionafteratransientdisconnection

3498cancelA2dpDeviceTimeout();

3499mDockAddress=address;

3500}else{

3501//thiscouldbeaconnectionofanotherA2DPdevicebeforethetimeoutof

3502//adock:

cancelthedocktimeout,andmakethedockunavailablenow

3503if(hasScheduledA2dpDockTimeout()){

3504cancelA2dpDeviceTimeout();

3505makeA2dpDeviceUnavailableNow(mDockAddress);

3506}

3507}

3508makeA2dpDeviceAvailable(address);

3509synchronized(mCurAudioRoutes){

3510Stringname=btDevice.getAliasName();

3511if(!

TextUtils.equals(mCurAudioRoutes.mBluetoothName,name)){

3512mCurAudioRoutes.mBluetoothName=name;

3513sendMsg(mAudioHandler,MSG_REPORT_NEW_ROUTES,

3514SENDMSG_NOOP,0,0,null,0);

3515}

3516}

3517}

3518}

3519}

makeA2dpDeviceUnavailableNow()@AudioService.java

3431//mustbecalledsynchronizedonmConnectedDevices

3432privatevoidmakeA2dpDeviceUnavailableNow(Stringaddress){

3433AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,********

3434AudioSystem.DEVICE_STATE_UNAVAILABLE,3435address);3436mConnectedDevices.remove(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);

3437}

Callthefollowingcpplayervianativemethod.

setDeviceConnectionState()@AudioSystem.cpp

574status_tAudioSystem:

:

setDeviceConnectionState(audio_devices_tdevice,

575audio_policy_dev_state_tstate,

576constchar*device_address)

577{

578constsp&aps=AudioSystem:

:

get_audio_policy_service();

579constchar*address="";

580

581if(aps==0)returnPERMISSION_DENIED;

582

583if(device_address!

=NULL){

584address=device_address;

585}

586

587returnaps->setDeviceConnectionState(device,state,address);**********

588}

Itiswaitingonblockingbinderio,

ExaminethreadAudioService'snativecallstack..#0__ioctl()atbionic/libc/arch-arm/syscalls/__ioctl.S:

10

#10x4028b030inioctl(fd=,request=-1072143871)atbionic/libc/bionic/ioctl.c:

41

#20x403f6c08inandroid:

:

IPCThreadState:

:

talkWithDriver(this=0x5cfe6a68,doReceive=)atframeworks/native/libs/binder/IPCThreadState.cpp:

817

#30x403f7134inandroid:

:

IPCThreadState:

:

waitForResponse(this=0x5cfe6a68,reply=0x5f3fac08,acquireResult=0x0)atframeworks/native/libs/binder/IPCThreadState.cpp:

679

#40x403f734einandroid:

:

IPCThreadState:

:

transact(this=0x5cfe6a68,handle=12,code=1,data=...,reply=0x5f3fac08,flags=16)

atframeworks/native/libs/binder/IPCThreadState.cpp:

570

#50x403f4aa6inandroid:

:

BpBinder:

:

transact(this=0x5e00d958,code=1,data=...,reply=0x5f3fac08,flags=0)atframeworks/native/libs/binder/BpBinder.cpp:

165

#60x4118c040inandroid:

:

BpAudioPolicyService:

:

setDeviceConnectionState(this=,device=AUDIO_DEVICE_OUT_BLUETOOTH_A2DP,

state=AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,device_address=0x5cfdefc0"00:

18:

13:

E0:

D1:

E3")atframeworks/av/media/libmedia/IAudioPolicyService.cpp:

87

#70x41180bcainandroid:

:

AudioSystem:

:

setDeviceConnectionState(device=AUDIO_DEVICE_OUT_BLUETOOTH_A2DP,state=AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,

device_address=)atframeworks/av/media/libmedia/AudioSystem.cpp:

577

#80x404c67d2inandroid_media_AudioSystem_setDeviceConnectionState(env=,thiz=,device=128,state=0,device_address=0x26500005)

atframeworks/base/core/jni/android_media_AudioSystem.cpp:

154

#90x40e0e3f4indvmPlatformInvoke()atdalvik/vm/arch/arm/CallEABI.S:

258

#100x40e3dbb2indvmCallJNIMethod(args=0x40f3de38,pResult=0x5ca26060,method=0x574408d8,self=0x5ca26050)atdalvik/vm/Jni.cpp:

1184

#110x40e178a4indalvik_mterp()atdalvik/vm/mterp/out/InterpAsm-armv7-a-neon.S:

16311

#120x40e1c40cindvmInterpret(self=0x5ca26050,method=,pResult=0x5f3faeb0)atdalvik/vm/interp/Interp.cpp:

1964

#130x40e50588indvmCallMethodV(self=0x5ca26050,method=0x57734dd0,obj=,fromJni=,pResult=0x5f3faeb0,args=...)

atdalvik/vm/interp/Stack.cpp:

526

#140x40e505b2indvmCallMethod(self=,method=,obj=,pResult=0x5f3faeb0)at

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 国外设计风格

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1