Displaying an AdWidget with another Platform view like GoogleMap or WebView freeze those views.
See original GitHub issueBug report
(Android only. iOS seems fine) I’ve got a screen containing a Platform view widget (Google Maps and/or WebView) As soon as the Adwidget is displayed (=once the load method is called), the others platform views freeze = i can not interact/scroll inside them anymore.
Steps to reproduce
Steps to reproduce the behavior:
Use those packages: google_maps_flutter: ^1.2.0 google_mobile_ads: ^0.11.0+1 webview_flutter: ^1.0.7
Use this code :
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'ad_state.dart';
class AdPage extends StatefulWidget {
AdPage({Key key}) : super(key: key);
@override
_AdPageState createState() => _AdPageState();
}
class _AdPageState extends State<AdPage> {
BannerAd banner;
bool isLoading = false;
@override
void initState() {
super.initState();
banner = BannerAd(
adUnitId: BannerAd.testAdUnitId,
size: AdSize.banner,
request: AdRequest(),
listener: AdState.adListener,
); //..load();
Future<void>.delayed(
Duration(seconds: 15),
() => setState(() {
banner?.load();
isLoading = true;
}));
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 300,
child: WebView(
javascriptMode: JavascriptMode.unrestricted,
initialUrl: "https://www.flutter.dev",
),
),
Container(
height: 300,
child: GoogleMap(
initialCameraPosition:
CameraPosition(target: LatLng(46.0, -0.36), zoom: 15.0)),
),
Container(
height: 50,
child: isLoading ? AdWidget(ad: banner) : null,
),
],
);
}
}
Flutter doctor
Run flutter doctor
and paste the output below:
Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H15 darwin-x64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[!] Android Studio (version 4.1)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.53.1)
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
Flutter dependencies
Run flutter pub deps -- --style=compact
and paste the output below:
Click To Expand
Dart SDK 2.10.5
Flutter SDK 1.22.6
google_mobile_ads_bug 1.0.0+1
dependencies:
- cupertino_icons 1.0.0
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- google_maps_flutter 1.2.0 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface]
- google_mobile_ads 0.11.0+1 [meta flutter]
- provider 4.3.3 [collection flutter nested]
- webview_flutter 1.0.7 [flutter]
dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]
transitive dependencies:
- async 2.5.0-nullsafety.1 [collection]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- collection 1.15.0-nullsafety.3
- fake_async 1.2.0-nullsafety.1 [clock collection]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- google_maps_flutter_platform_interface 1.2.0 [flutter meta plugin_platform_interface stream_transform collection]
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- nested 0.0.4 [flutter]
- path 1.8.0-nullsafety.1
- plugin_platform_interface 1.0.3 [meta]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- stream_transform 1.2.0
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- vector_math 2.1.0-nullsafety.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:29
Top Results From Across the Web
Camera and view | Maps SDK for Android - Google Developers
Like Google Maps on the web, the Maps SDK for Android represents the world's surface ... When you change the viewing angle, the...
Read more >Freeze or make Stable Web-view When I Select Action Bar ...
I have just performed a test using two activities, a MainActivity containing a webView just like yours, and a menu button that opens...
Read more >[ROM]【4.4.4】Google Play Edition【JFLTE-GPE ... - XDA Forums
Question, I'm getting a 'Couldn't add widget' message at the top of the app switcher ... I still have audio issues while playing...
Read more >https://static1.squarespace.com/static/5fbb3998e3c...
The quality functionality like comparing apples oranges opinion. ... opportunity to watch where some buses are currently online (that is, displayed as in ......
Read more >How to fix Maps when it crashes - Android - Google Maps Help
If the Google Maps app on your phone or tablet crashes or has other issues that affect your experience on Maps, try the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
WebView already supports hybrid composition and GoogleMaps has been updated with: flutter/flutter#78578. See https://pub.dev/packages/webview_flutter and https://pub.dev/packages?q=google_maps_flutter for more information on how to use Hybrid Composition with either of the plugins.
Hi, I have a similar problem, but for me it’s not freezing. I get a crash in my app (which starts up and displays a GoogleMap widget and a placeholder for a BannerAd). In the init of my app I initialise Mobile Ads, and then I have a BannerAdState widget, using a listener / banner completer, as per the example.
If I put a delay (say 30 seconds or so) on the “load()” method of the banner ad, then my app loads and I can do some interactions with all aspects of the app (including the Google Map), but then once the “complete()” method of the banner ad completer runs, and the BannerAd widget actually tries to display the ad, I get the following crash:
===========================================================================
F/libc (10126): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 10150 (RenderThread), pid 10126 (.shows_near_me1)
Build fingerprint: ‘google/sdk_gphone_x86/generic_x86:10/QSR1.190920.001/5891938:user/release-keys’ Revision: ‘0’ ABI: ‘x86’ Timestamp: 2021-03-13 14:00:29+1100 pid: 10126, tid: 10150, name: RenderThread >>> com.example.shows_near_me1 <<< uid: 10148 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference eax cc831000 ebx d87be864 ecx d86285c0 edx 0000001d edi c8f8d328 esi cc950400 ebp c8f8d2ec esp c8f8d28c eip 00000000 backtrace: #00 pc 00000000 <unknown> #01 pc 0286c771 /system/product/app/TrichromeLibrary/TrichromeLibrary.apk!libmonochrome.so (offset 0x66c000) (BuildId: ffe50d4377c82928759c1f40f1b35ba9f411454a) Lost connection to device. Exited (sigterm)
===========================================================================
It is only the final step of displaying the actual BannerAd widget that causes the crash, and the crash only occurs if the GoogleMap widget is also shown. That is, the following occurs without a crash: