[Android]-Admob配置过多导致的慢消息

在使用BlockCanary检测慢消息时,遇到了这样的一个日志:

从日志中,可以初步判断,是由于谷歌的广告sdk,调用了Uri.decode方法.

typescript 复制代码
public static String decode(String s) {
    if (s == null) {
        return null;
    }
    return UriCodec.decode(
            s, false /* convertPlus */, StandardCharsets.UTF_8, false /* throwOnFailure */);
}

这不禁让我好奇,究竟是什么样的字符串,能耗时(500ms~10003ms)呢。

为了一探究竟,我通过代码插桩的方式,在decode方法执行前,尝试输出了字符串的内容(由于Logcat显示长度受限,只能写入文件)。最终写入文件的大小为273KB。

很多小伙伴可能会比较好奇,文件里的内容究竟长什么样呢?下面是脱敏后的字符串样例。截取了一部分。

json 复制代码
{
  "param": {
    "isSuccessful": true,
    "appSettingsJson": {
      "status": 1,
      "app_id": "ca-app-pub-3940256099942544~3347511713",
      "auto_collect_location": false,
      "initializer_settings": {
        "config": {
          "com.google.ads.mediation.admob.AdMobAdapter": {
            "data": [
              {"format": "interstitial"},
              {"format": "banner"},
            //省略若干行............................
              {"format": "banner"},
              {"format": "interstitial"},
              {"format": "rewarded"},
              {"format": "interstitial"},
              {"format": "native"}
            ]
          },
          "com.google.ads.mediation.applovin.AppLovinMediationAdapter": {
            "data": [
              {
                "format": "interstitial",
                "data": {
                  "sdkKey": "nR5tzXVaLE7HJipKAA_kvMFqRd-eyJt3ZDQYMcLnwqVRg9PP9kuRR2tkkh83rY7WMe9LFK4_6ydRpXTxWS83-x"
                }
              },
              {
                "format": "interstitial",
                "data": {
                  "sdkKey": "nR5tzXVaLE7HJipKAA_kvMFqRd-eyJt3ZDQYMcLnwqVRg9PP9kuRR2tkkh83rY7WMe9LFK4_6ydRpXTxWS83-x"
                }
              },
              {
                "format": "interstitial",
                "data": {
                  "sdkKey": "nR5tzXVaLE7HJipKAA_kvMFqRd-eyJt3ZDQYMcLnwqVRg9PP9kuRR2tkkh83rY7WMe9LFK4_6ydRpXTxWS83-x"
                }
              }
            ]
          },
          "com.google.ads.mediation.inmobi.InMobiMediationAdapter": {
            "data": [
              {
                "format": "banner",
                "data": {
                  "accountid": "c92e1f4b8d2a4e60b3d179ad6e8c5f7a",
                  "placementid": "19999942638"
                }
              },
              {
              //省略若干行
                "format": "banner",
                "data": {
                  "accountid": "c92e1f4b8d2a4e60b3d179ad6e8c5f7a",
                  "placementid": "199999142509"
                }
              }
              }
            ]
          },
          "com.google.ads.mediation.mintegral.MintegralMediationAdapter": {
            "data": [
              {
                "format": "interstitial",
                "data": {
                  "ad_unit_id": "1234567",
                  "app_id": "123456",
                  "app_key": "a6c1e3dabf2d4a7e8c13f47a9d85b21f",
                  "placement_id": "1234567"
                }
              },
                //省略若干行
              {
                "format": "interstitial",
                "data": {
                  "ad_unit_id": "1234567",
                  "app_id": "123456",
                  "app_key": "a6c1e3dabf2d4a7e8c13f47a9d85b21f",
                  "placement_id": "1234567"
                }
              }
            ]
          },
          "com.google.ads.mediation.pangle.PangleMediationAdapter": {
            "data": [
              {
                "format": "banner",
                "data": {
                  "appid": "1234567",
                  "placementid": "123456789"
                }
              }
          }
        }

从内容我们知道,这是我们在Admob后台配置的广告ID,以及聚合的第三方广告平台的广告信息。由于项目历史悠久,长久以来产品同学配置的广告ID,仅Admob一家就有约500个。算上聚合的其他平台,数量就更多了。后续,我们将和产品同学一起,优化相关的配置,提升用户体验。

相关推荐
柿蒂1 小时前
聊聊SliverPersistentHeader优先消费滑动的设计
android·flutter
假装多好1233 小时前
android三方调试几个常用命令
android·1024程序员节·三方,gms
侧耳4293 小时前
android11禁止安装apk
android·java·1024程序员节
JohnnyDeng944 小时前
ArkTs-Android 与 ArkTS (HarmonyOS) 存储目录全面对比
android·harmonyos·arkts·1024程序员节
2501_915918414 小时前
iOS 26 查看电池容量与健康状态 多工具组合的工程实践
android·ios·小程序·https·uni-app·iphone·webview
limingade5 小时前
手机摄像头如何识别体检的色盲检查图的数字和图案(下)
android·1024程序员节·色盲检查图·手机摄像头识别色盲图案·android识别色盲检测卡·色盲色弱检测卡
文火冰糖的硅基工坊5 小时前
[嵌入式系统-150]:智能机器人(具身智能)内部的嵌入式系统以及各自的功能、硬件架构、操作系统、软件架构
android·linux·算法·ubuntu·机器人·硬件架构
2501_915909066 小时前
iOS 架构设计全解析 从MVC到MVVM与使用 开心上架 跨平台发布 免Mac
android·ios·小程序·https·uni-app·iphone·webview
明道源码7 小时前
Android Studio 创建 Android 模拟器
android·ide·android studio
明道源码7 小时前
Android Studio 使用教程
android·ide·android studio