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

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: [email protected] (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: [email protected] (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的调整入口,不让测试或者正常用户使用。
相关推荐
思茂信息1 小时前
CST软件对OPERA&CST软件联合仿真汽车无线充电站对人体的影响
c语言·开发语言·人工智能·matlab·汽车·软件构建
CGG922 小时前
【单例模式】
android·java·单例模式
kp000003 小时前
PHP弱类型安全漏洞解析与防范指南
android·开发语言·安全·web安全·php·漏洞
编程乐学(Arfan开发工程师)8 小时前
06、基础入门-SpringBoot-依赖管理特性
android·spring boot·后端
androidwork8 小时前
使用 Kotlin 和 Jetpack Compose 开发 Wear OS 应用的完整指南
android·kotlin
繁依Fanyi9 小时前
Animaster:一次由 CodeBuddy 主导的 CSS 动画编辑器诞生记
android·前端·css·编辑器·codebuddy首席试玩官
奔跑吧 android11 小时前
【android bluetooth 框架分析 02】【Module详解 6】【StorageModule 模块介绍】
android·bluetooth·bt·aosp13·storagemodule
Dotrust东信创智15 小时前
面向SDV的在环测试深度解析——仿真中间件SIL KIT应用篇
网络·中间件·汽车
田一一一15 小时前
Android framework 中间件开发(三)
android·中间件·framework·jni
androidwork20 小时前
掌握 Kotlin Android 单元测试:MockK 框架深度实践指南
android·kotlin