Skip to content

WebView makes app crash if it is too big (Virtual display only) #93115

@mateusfccp

Description

@mateusfccp

This is the same as #28978, but I opened another issue because the former was closed and locked without any proper solution.

In my device, differently from #28978, the app crashed and closed, but the device did not restart.

As noted by @danagbemava-nc, this issue does not happen when in hybrid composition mode.

Steps to Reproduce

  1. Consider the following, minimal, reproducible example:
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(
    const MaterialApp(
      home: CrashingWebViewExample(),
    ),
  );
}

class CrashingWebViewExample extends StatelessWidget {
  const CrashingWebViewExample({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const SingleChildScrollView(
      child: SizedBox(
        // If the crash does not happens with 10000, try increasing it. The size required to reproduce may vary from device to device.
        height: 10000,
        child: WebView(
          initialUrl: 'https://en.wikipedia.org/wiki/Cephalopod_size',
        ),
      ),
    );
  }
}
  1. Try running it on Android.

Expected results:

The app runs and shows a webview that has the passed height, showing all the content of the rendered URL.

Actual results:

The app crashes with a warning.
This warning was introduced in flutter/engine#8704 and flutter/engine#9110.

W/PlatformViewsController(19084): Creating a virtual display of size: [1080, 25500] may result in problems(https://github.com/flutter/flutter/issues/2897).It is larger than the device screen size: [1080, 2065].
E/InputMethodManager(19084): b/117267690: Failed to get fallback IMM with expected displayId=44 actual IMM#displayId=0 view=io.flutter.plugins.webviewflutter.InputAwareWebView{9c12899 VFEDHVC.. ........ 0,0-1080,4316}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: crashStack traces logged to the consolec: fatal crashCrashes that terminate the processfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyplatform-views: vdIssues specific to the Android VirtualDisplay platform views backendteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions