Skip to content

[webview_flutter_tizen] Webview crashes when impeller is enabled #933

@JSUYA

Description

@JSUYA

When webview_flutter_tizen uses MaterialPageRoute to display a new page and pops it clicking the back key, a crash occurs.
It doesn't occur 100% of the time, but it occurs 5 out of 10 times during repeated testing.
The problem is that this issue only occurs when impeller is enabled.
The segfault occurs in libchromium-efl, but since the issue occurs only in the impeller case, I believe a fix is ​​possible in the embedder or webview.

The log below was run on RPI + Tizen 10.0, but the issue is the same on Tizen 9.0 TV.

  webview_flutter: ^4.10.0
  webview_flutter_tizen: ^0.9.6

main.dart

import 'package:flutter/material.dart';
import 'webview_screen.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.green,
      appBar: AppBar(title: const Text('Flutter WebView example')),
      body: ElevatedButton(
        onPressed: () {
          Navigator.push(
            context,
            MaterialPageRoute(
              builder: (_) => WebViewScreen(url: 'https://flutter.dev'),
            ),
          );
        },
        child: Text('open'),
      ),
    );
  }
}

webview_screen.dart

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewScreen extends StatefulWidget {
  final String url;
  const WebViewScreen({super.key, required this.url});

  @override
  State<WebViewScreen> createState() => _WebViewScreenState();
}

class _WebViewScreenState extends State<WebViewScreen> {
  late final WebViewController? _controller;

  @override
  void initState() {
    super.initState();

    WidgetsBinding.instance.addPostFrameCallback((_) {
      late final PlatformWebViewControllerCreationParams params;
      params = const PlatformWebViewControllerCreationParams();

      var controller = WebViewController.fromPlatformCreationParams(params);

      controller
        ..setJavaScriptMode(JavaScriptMode.unrestricted)
        ..setNavigationDelegate(
          NavigationDelegate(
            onProgress: (int progress) {
              debugPrint('Page started loading: $progress / 100 ');
            },
            onPageStarted: (String url) {
              debugPrint('Page loading started url : $url');
            },
            onPageFinished: (String url) {
              debugPrint('Page loading finished url : $url ');
            },
            onWebResourceError: (WebResourceError error) {},
          ),
        )
        ..addJavaScriptChannel(
          'Toaster',
          onMessageReceived: (JavaScriptMessage message) {
            ScaffoldMessenger.of(
              context,
            ).showSnackBar(SnackBar(content: Text(message.message)));
          },
        )
        ..loadRequest(Uri.parse(widget.url));

      setState(() {
        _controller = controller;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    if (_controller == null) return Container();

    return Scaffold(
      appBar: AppBar(title: const Text('Flutter WebView')),
      body: WebViewWidget(controller: _controller),
    );
  }
}
[E] Received signal 11 SEGV_MAPERR 000000000000
[E] #0 0xffbe36f32b40 (/usr/share/chromium-efl/lib/libchromium-impl.so+0x7f92b3f)
#1 0xffbe36f23404
[E] (/usr/share/chromium-efl/lib/libchromium-impl.so+0x7f83403)
#2 0xffbe36f329f8
[E] (/usr/share/chromium-efl/lib/libchromium-impl.so+0x7f929f7)
#3 0xffffad1cc828
[E] ([vdso]+0x827)
[E]
#4
[E]  0xffbea0eb00f0
[E] (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x4300ef)
#5 0xffbea0bff4f8 (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x17f4f7)
#6 0xffbea0bff2bc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x17f2bb)
#7 0xffbea11269dc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x6a69db)
#8 0xffbea111cdfc
[E] (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x69cdfb)
#9 0xffbea1126fbc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x6a6fbb)
#10 0xffbea111cdfc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x69cdfb)
#11 0xffbea1126fbc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x6a6fbb)
#12 0xffbea111cdfc
[E] (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x69cdfb)
#13 0xffbea1126fbc
[E] (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x6a6fbb)
#14 0xffbea111cdfc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x69cdfb)
#15 0xffbea1126fbc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x6a6fbb)
#16 0xffbea111cdfc (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x69cdfb)
#17 0xffbea112423c (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x6a423b)
#18 0xffbea135a6f4 (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x8da6f3)
#19 0xffbea0c33298 (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x1b3297)
#20 0xffbea0c3a540 (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x1ba53f)
#21 0xffbea0c3314c (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x1b314b)
#22 0xffbea0c39468
[E] (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x1b9467)
#23 0xffbea0c39058 (/opt/usr/dotnet/Libraries/libflutter_engine.so..cd904cc3fc6ac0fdbddf4e396211c8ba3386b392c242a5a3110be8ed8796bb50+0x1b9057)
#24 0xffffacbde5cc (/usr/lib64/libc.so.6+0x7e5cb)
#25 0xffffacc3ca4c
[E] (/usr/lib64/libc.so.6+0xdca4b)
[E]
[end of stack trace]

+)

There is a case where a crash occurs more clearly.
The code below also works normally with the skia renderer.

(webview_screen.dart)

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebViewScreen extends StatefulWidget {
  final String url;
  const WebViewScreen({super.key, required this.url});

  @override
  State<WebViewScreen> createState() => _WebViewScreenState();
}

class _WebViewScreenState extends State<WebViewScreen> {
  late final WebViewController? _controller;

  @override
  void initState() {
    super.initState();

    late final PlatformWebViewControllerCreationParams params;
    params = const PlatformWebViewControllerCreationParams();

    _controller = WebViewController.fromPlatformCreationParams(params);
    if (_controller != null) {
      _controller
        ..setJavaScriptMode(JavaScriptMode.unrestricted)
        ..setNavigationDelegate(
          NavigationDelegate(
            onProgress: (int progress) {
              debugPrint('Page started loading: $progress / 100 ');
            },
            onPageStarted: (String url) {
              debugPrint('Page loading started url : $url');
            },
            onPageFinished: (String url) {
              debugPrint('Page loading finished url : $url ');
            },
            onWebResourceError: (WebResourceError error) {},
          ),
        )
        ..addJavaScriptChannel(
          'Toaster',
          onMessageReceived: (JavaScriptMessage message) {
            ScaffoldMessenger.of(
              context,
            ).showSnackBar(SnackBar(content: Text(message.message)));
          },
        )
        ..loadRequest(Uri.parse(widget.url));
    }
  }

  @override
  Widget build(BuildContext context) {
    if (_controller == null) return Container();

    return Scaffold(
      appBar: AppBar(title: const Text('Flutter WebView')),
      body: WebViewWidget(controller: _controller),
    );
  }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions