唤醒车机时娱乐屏出现黑屏,卡顿的案例分享

1. 背景

测试在正常操作车机的时候,出现了:唤醒车机时娱乐屏出现连续两次黑屏,且发现系统有卡顿的现象。

2. log分析

  • low_memory_killer 杀掉adj=100的visible进程,是因为memory 不足导致的。
html 复制代码
行 16839: 10-26 16:22:11.900235   264   264 I lowmemorykiller: Kill 'com.bilibili.bilithings:ijkservice' (19543), uid 10045, oom_adj 200 to free 65668kB
	行 16840: 10-26 16:22:11.900316   264   264 I lowmemorykiller: Reclaimed 65668kB, cache(209812kB) and free(52500kB)-reserved(150240kB) below min(224692kB) for oom_adj 200
	行 16854: 10-26 16:22:11.918705   264   264 I lowmemorykiller: Kill 'com.android.inputmethod' (15307), uid 10020, oom_adj 200 to free 55604kB
	行 16855: 10-26 16:22:11.918735   264   264 I lowmemorykiller: Reclaimed 55604kB, cache(209292kB) and free(73144kB)-reserved(150240kB) below min(224692kB) for oom_adj 200
	行 17672: 10-26 16:22:12.369378   264   264 W lowmemorykiller: Failed to open /proc/11439/oom_score_adj; errno=2: process 11439 might have been killed
	行 18564: 10-26 16:22:12.916724   264   264 I lowmemorykiller: Reclaimed 0kB, cache(234016kB) and free(19076kB)-reserved(150240kB) below min(262144kB) for oom_adj 250
	行 18565: 10-26 16:22:12.916832   264   264 I lowmemorykiller: Suppressed 90 failed kill reports
	行 19690: 10-26 16:22:13.882001   264   264 I lowmemorykiller: Kill 'com.android.launcher' (2036), uid 1000, oom_adj 100 to free 493428kB
	行 19691: 10-26 16:22:13.882084   264   264 I lowmemorykiller: Reclaimed 493428kB, cache(186928kB) and free(12132kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 19692: 10-26 16:22:13.882106   264   264 I lowmemorykiller: Suppressed 29 failed kill reports
	行 19704: 10-26 16:22:13.887833   264   264 I lowmemorykiller: Kill 'com.android.media' (2937), uid 10029, oom_adj 100 to free 226284kB
	行 19705: 10-26 16:22:13.887862   264   264 I lowmemorykiller: Reclaimed 226284kB, cache(183808kB) and free(13916kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 20857: 10-26 16:22:14.882659   264   264 I lowmemorykiller: Reclaimed 0kB, cache(237948kB) and free(12096kB)-reserved(150240kB) below min(262144kB) for oom_adj 250
	行 20858: 10-26 16:22:14.882715   264   264 I lowmemorykiller: Suppressed 94 failed kill reports
	行 21610: 10-26 16:22:15.763508   264   264 I lowmemorykiller: Kill 'com.android.local.scene' (3278), uid 1000, oom_adj 100 to free 136676kB
	行 21611: 10-26 16:22:15.763572   264   264 I lowmemorykiller: Reclaimed 136676kB, cache(185368kB) and free(13676kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 21612: 10-26 16:22:15.763594   264   264 I lowmemorykiller: Suppressed 3 failed kill reports
	行 22183: 10-26 16:22:16.463138   264   264 I lowmemorykiller: Kill 'com.android.energycenter' (3254), uid 10030, oom_adj 100 to free 119084kB
	行 22184: 10-26 16:22:16.463160   264   264 I lowmemorykiller: Reclaimed 119084kB, cache(183628kB) and free(13204kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 22185: 10-26 16:22:16.463167   264   264 I lowmemorykiller: Suppressed 64 failed kill reports
	行 22193: 10-26 16:22:16.477960   264   264 I lowmemorykiller: Kill 'com.android.btphone' (2126), uid 10028, oom_adj 100 to free 67280kB
	行 22194: 10-26 16:22:16.477977   264   264 I lowmemorykiller: Reclaimed 67280kB, cache(180636kB) and free(34372kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 22199: 10-26 16:22:16.481801   264   264 I lowmemorykiller: Kill 'com.android.carplay' (2446), uid 1000, oom_adj 100 to free 66228kB
	行 22200: 10-26 16:22:16.481822   264   264 I lowmemorykiller: Reclaimed 66228kB, cache(178556kB) and free(39916kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 22219: 10-26 16:22:16.499102   264   264 I lowmemorykiller: Kill 'com.android.permissioncontroller' (2322), uid 10043, oom_adj 100 to free 63492kB
	行 22220: 10-26 16:22:16.499117   264   264 I lowmemorykiller: Reclaimed 63492kB, cache(172056kB) and free(99560kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 22230: 10-26 16:22:16.515621   264   264 I lowmemorykiller: Kill 'android.ext.services' (1731), uid 10039, oom_adj 100 to free 54652kB
	行 22231: 10-26 16:22:16.515644   264   264 I lowmemorykiller: Reclaimed 54652kB, cache(167376kB) and free(118736kB)-reserved(150240kB) below min(187244kB) for oom_adj 100
	行 22289: 10-26 16:22:16.535189   264   264 I lowmemorykiller: Kill 'com.android.linkmanager' (2296), uid 1000, oom_adj 100 to free 52544kB

从/android/frameworks/base/services/core/java/com/android/server/am/ProcessList.java

可以看到adj=100的定义:VISIBLE_APP_ADJ,从google的描述来看,adj=100的进程是可见activity对应的进程,不应被杀掉。

java 复制代码
    // This is a process bound by the system (or other app) that's more important than services but
    // not so perceptible that it affects the user immediately if killed.
    public static final int PERCEPTIBLE_LOW_APP_ADJ = 250;

    // This is a process hosting services that are not perceptible to the user but the
    // client (system) binding to it requested to treat it as if it is perceptible and avoid killing
    // it if possible.
    public static final int PERCEPTIBLE_MEDIUM_APP_ADJ = 225;

    // This is a process only hosting components that are perceptible to the
    // user, and we really want to avoid killing them, but they are not
    // immediately visible. An example is background music playback.
    public static final int PERCEPTIBLE_APP_ADJ = 200;

    // This is a process only hosting activities that are visible to the
    // user, so we'd prefer they don't disappear.
    public static final int VISIBLE_APP_ADJ = 100;
    static final int VISIBLE_APP_LAYER_MAX = PERCEPTIBLE_APP_ADJ - VISIBLE_APP_ADJ - 1;

    // This is a process that was recently TOP and moved to FGS. Continue to treat it almost
    // like a foreground app for a while.
    // @see TOP_TO_FGS_GRACE_PERIOD
    public static final int PERCEPTIBLE_RECENT_FOREGROUND_APP_ADJ = 50;

    // This is the process running the current foreground app.  We'd really
    // rather not kill it!
    public static final int FOREGROUND_APP_ADJ = 0;

    // This is a process that the system or a persistent process has bound to,
    // and indicated it is important.
    public static final int PERSISTENT_SERVICE_ADJ = -700;
  • log进程占用内存过大触发low memory
html 复制代码
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ?? 1650301: logmgr (pid 855) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   77679: surfaceflinger (pid 497) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   58900: logd (pid 263) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   16023: android.hardware.automotive.vehicle@2.0-service (pid 428) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   15327: media.extractor (pid 764) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   13763: audioserver (pid 486) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   12345: media.metrics (pid 767) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   11470: zygote (pid 389) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??   10143: webview_zygote (pid 1542) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    7932: mediaserver (pid 769) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    7912: media.swcodec (pid 781) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    7103: cameraserver (pid 742) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    6721: android.hardware.graphics.composer@2.4-service (pid 442) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    6605: android.hardware.audio.service (pid 274) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    6383: init (pid 1) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    6122: zygote64 (pid 388) native
10-26 16:22:13.489428  1111 11527 I ActivityManager:   ntv   ??    5720: media.hwcodec (pid 462) native
  • Log V等级的log大量打印,导致logd进程来不及输出,占用内存所致。
html 复制代码
	行    89: 10-26 16:22:02.900211   622 16572 V tbox_client: wait heartbeat signal timeout
	行    92: 10-26 16:22:02.900295   622 16572 V tbox_client: BaseMessageInterface
	行    93: 10-26 16:22:02.900319   622 16572 V tbox_client: init BaseMessageInterface new message:0xb400007665043780 data:0xb4000076e50310b0
	行    94: 10-26 16:22:02.900575   622 16572 V tbox_client: wait for heartbeat signal
	行    98: 10-26 16:22:02.900927   622 16123 V tbox_client: ~BaseMessageInterface ~BaseMessageInterface delete message:0xb400007665043780 data:0xb4000076e50310b0
	行   101: 10-26 16:22:02.901545   428 16144 V ANDROID_SOMEIP: SOME/IP-RM [0x0000] received message [NOTIFICATION] on service [0x0301:0x8003:0x0001]
	行   102: 10-26 16:22:02.901622   428 16144 V ANDROID_SOMEIP: Received [NOTIFICATION] message from Client [0x0000] for a Service [0x0301:0x0001] Method [0x8003] with len [33]
	行   103: 10-26 16:22:02.901638   428 16144 V ANDROID_SOMEIP: SOME/IP-SA received message [2] on Service [0x0301:0x0001:0x8003] client [0x0000] len [1]
	行   104: 10-26 16:22:02.901755   428   508 V -BIND   : [COM Callback: 0x0301:0x0001:0x8003]
	行   106: 10-26 16:22:02.902100   428 16144 V ANDROID_SOMEIP: SOME/IP-RM [0x0000] received message [NOTIFICATION] on service [0x0302:0x8001:0x0001]
	行   107: 10-26 16:22:02.902137   428 16144 V ANDROID_SOMEIP: Received [NOTIFICATION] message from Client [0x0000] for a Service [0x0302:0x0001] Method [0x8001] with len [103]
	行   108: 10-26 16:22:02.902202   428 16144 V ANDROID_SOMEIP: SOME/IP-SA received message [2] on Service [0x0302:0x0001:0x8001] client [0x0000] len [71]
	行   109: 10-26 16:22:02.902270   428   508 V -BIND   : [COM Callback: 0x0302:0x0001:0x8001]
	行   211: 10-26 16:22:02.941557   428 16144 V ANDROID_SOMEIP: SOME/IP-RM [0x0000] received message [NOTIFICATION] on service [0x0302:0x8001:0x0001]
	行   212: 10-26 16:22:02.941629   428 16144 V ANDROID_SOMEIP: Received [NOTIFICATION] message from Client [0x0000] for a Service [0x0302:0x0001] Method [0x8001] with len [103]
	行   213: 10-26 16:22:02.941647   428 16144 V ANDROID_SOMEIP: SOME/IP-SA received message [2] on Service [0x0302:0x0001:0x8001] client [0x0000] len [71]
	行   214: 10-26 16:22:02.941731   428 16144 V ANDROID_SOMEIP: SOME/IP-RM [0x0000] received message [NOTIFICATION] on service [0x0301:0x8003:0x0001]
	行   215: 10-26 16:22:02.941753   428 16144 V ANDROID_SOMEIP: Received [NOTIFICATION] message from Client [0x0000] for a Service [0x0301:0x0001] Method [0x8003] with len [33]
	行   216: 10-26 16:22:02.941762   428 16144 V ANDROID_SOMEIP: SOME/IP-SA received message [2] on Service [0x0301:0x0001:0x8003] client [0x0000] len [1]
	行   217: 10-26 16:22:02.941828   428   508 V -BIND   : [COM Callback: 0x0301:0x0001:0x8003]
	行   219: 10-26 16:22:02.941961   428   508 V -BIND   : [COM Callback: 0x0302:0x0001:0x8001]
	行   286: 10-26 16:22:02.964688  1111  1156 V SettingsProvider: callingUid=1000 call([settings, PUT_global, android_car_info_driving_speed, Bundle[{_user=0, value=48}]]) = null
	行   293: 10-26 16:22:02.967693  1111 11173 V SettingsProvider: callingUid=1000 call([settings, GET_global, dropbox_age_seconds, null]) = Bundle[{value=null}]
	行   295: 10-26 16:22:02.967786  1111 11173 V SettingsProvider: callingUid=1000 call([settings, GET_global, dropbox_max_files, null]) = Bundle[{value=null}]
	行   297: 10-26 16:22:02.967866  1111 11173 V SettingsProvider: callingUid=1000 call([settings, GET_global, dropbox_quota_percent, null]) = Bundle[{value=null}]
	行   298: 10-26 16:22:02.968010  1111 11173 V SettingsProvider: callingUid=1000 call([settings, GET_global, dropbox_reserve_percent, null]) = Bundle[{value=null}]
	行   300: 10-26 16:22:02.968181  1111 11173 V SettingsProvider: callingUid=1000 call([settings, GET_global, dropbox_quota_kb, null]) = Bundle[{value=null}]
	行   311: 10-26 16:22:02.971871  1111  5423 V SettingsProvider: callingUid=1000 call([settings, GET_global, com.android.assistant.full_wakeup_free.enable, null]) = Bundle[{value=null}]
	行   313: 10-26 16:22:02.972473  1111 17082 V SettingsProvider: callingUid=1000 call([settings, GET_global, driving_video_limit_key, null]) = Bundle[{value=0}]
  • logd输出如下log表示logd出现了内存不足的情况:
    行 1503: 10-26 16:22:03.451576 0 0 D logd : Kicking blocked reader, pid 855, from LogBuffer::kickMe()
    行 1508: 10-26 16:22:03.452153 0 0 D logd : Kicking blocked reader, pid 855, from LogBuffer::kickMe()

3. 修改方案

  • 精简log V的log
  • 工程模式去掉log V的调整入口,不让测试或者正常用户使用。
相关推荐
Eastsea.Chen1 小时前
MTK Android12 user版本MtkLogger
android·framework
长亭外的少年9 小时前
Kotlin 编译失败问题及解决方案:从守护进程到 Gradle 配置
android·开发语言·kotlin
建群新人小猿11 小时前
会员等级经验问题
android·开发语言·前端·javascript·php
哔哥哔特商务网11 小时前
一文探究48V新型电气架构下的汽车连接器
架构·汽车
1024小神12 小时前
tauri2.0版本开发苹果ios和安卓android应用,环境搭建和最后编译为apk
android·ios·tauri
兰琛12 小时前
20241121 android中树结构列表(使用recyclerView实现)
android·gitee
电子科技圈13 小时前
IAR与鸿轩科技共同推进汽车未来
科技·嵌入式硬件·mcu·汽车
Y多了个想法13 小时前
RK3568 android11 适配敦泰触摸屏 FocalTech-ft5526
android·rk3568·触摸屏·tp·敦泰·focaltech·ft5526
NotesChapter14 小时前
Android吸顶效果,并有着ViewPager左右切换
android
hfxns_15 小时前
iPhone12手机通话记录删除了怎么恢复?3个方法快速恢复
智能手机