我想这很难也不可能说什么,但我还是想试试。我刚改用
google_mobile_ads
我的Flutter应用程序中的库用于显示横幅广告。它工作正常,尽管我在列表中显示这些广告时确实看到了一些性能问题。我认为这与作为网络视图的横幅渲染有关,我可以想象这相当慢。
总之,在iOS上,我在上下滚动列表很多次后出现崩溃,从日志中看,这可能与广告库有关。
我继续跑
iPhone OS 14.4.2 (18D70)
在a
iPhone8,1
。这是我得到的日志:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Application Specific Information:
abort() called
Last Exception Backtrace:
0 CoreFoundation 0x1a08b19d8 __exceptionPreprocess + 216
1 libobjc.A.dylib 0x1b4c34b54 objc_exception_throw + 55
2 CoreFoundation 0x1a091bd98 _CFThrowFormattedException + 111
3 CoreFoundation 0x1a09271f4 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:].cold.4 + 47
4 CoreFoundation 0x1a07ac8a8 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 239
5 CoreFoundation 0x1a079fc04 +[NSDictionary dictionaryWithObjects:forKeys:count:] + 55
6 Runner 0x1006d7688 -[FLTAdInstanceManager onAdLoaded:responseInfo:] + 2340488 (FLTAdInstanceManager_Internal.m:82)
7 Runner 0x1006d5268 -[FLTBannerAd bannerViewDidReceiveAd:] + 2331240 (FLTAd_Internal.m:207)
8 Runner 0x1005ef224 GAD_GADBannerView_arm64_8_5_0 + 5139
9 Runner 0x1006433f8 __destroy_helper_block_e8_32s40s48s56s64s72w + 159
不确定这是否与我加载广告的方式有关,但我基本上遵循了这个例子
the official codelabs
。它看起来像这样:
void initState() {
super.initState();
final adUnit = DebugPlaceholder.isDebugMode
? debugAdUnit
: liveAdUnit;
_ad = BannerAd(
adUnitId: adUnit,
size: AdSize.largeBanner,
request: AdRequest(),
listener: BannerAdListener(
onAdLoaded: (_) {
setState(() {
_adLoaded = true;
});
},
onAdFailedToLoad: (ad, error) {
_ad.dispose();
print('Ad load failed (code=${error.code} message=${error.message})');
}
)
);
_ad.load();
}
@override
void dispose() {
_ad.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (!_adLoaded) return Container();
return Container(
color: Colors.white,
alignment: Alignment.center,
height: _ad.size.height.toDouble(),
width: _ad.size.width.toDouble(),
child: AdWidget(ad: _ad)
);
}
任何提示,即使不是关于实际问题,而是关于如何排除故障,也非常感谢!