MixinNetwork / MixinNetwork/flutter-plugins

Black Screen when I open webview

Open
#290 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
512
Forks
292
Avg merge
15h 8m
Merged PRs (30d)
7

Description

Greetings! I'm trying to open a webpage with desktop_webview_window. But when I do it I get this error

Inspection is enabled by default for process or parent application with 'com.apple.security.get-task-allow' entitlement linked against old SDK. Use `inspectable` API to enable inspection on newer SDKs.

════════ Exception caught by Flutter framework ═════════════════════════════════
The following assertion was thrown during runApp:
Zone mismatch.

The Flutter bindings were initialized in a different zone than is now being used. This will likely cause confusion and bugs as any zone-specific configuration will inconsistently use the configuration of the original binding initialization zone or this zone based on hard-to-predict factors such as which zone was active when a particular callback was set.
It is important to use the same zone when calling `ensureInitialized` on the binding as when calling `runApp` later.
To make this warning fatal, set BindingBase.debugZoneErrorsAreFatal to true before the bindings are initialized (i.e. as the first statement in `void main() { }`).
When the exception was thrown, this was the stack
#0      BindingBase.debugCheckZone.<anonymous closure>
binding.dart:497
#1      BindingBase.debugCheckZone
binding.dart:502
#2      runApp
binding.dart:1080
#3      runWebViewTitleBarWidget.<anonymous closure>
title_bar.dart:34
#8      runWebViewTitleBarWidget
title_bar.dart:31
#9      main
main.dart:7
#10     _runMain.<anonymous closure> (dart:ui/hooks.dart:129:23)
#11     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:296:19)
#12     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
(elided 4 frames from dart:async)
════════════════════════════════════════════════════════════════════════════════

If I try to open the webview again I get this error too

"load url: https://www.google.com/"
<desktop_webview_window.WebviewWindowController: 0x7f90a8b9a7d0> deinited
<desktop_webview_window.WebViewLayoutController: 0x7f90a88f6870> deinited
"load url: https://www.google.com/"
embedder.cc (2372): 'FlutterEngineSendPlatformMessage' returned 'kInvalidArguments'. Invalid engine handle.
2023-09-25 16:12:16.879 desktop_platform_ch[27921:355518] Failed to send message to Flutter engine on channel 'webview_message/client_channel' (2).
embedder.cc (2372): 'FlutterEngineSendPlatformMessage' returned 'kInvalidArguments'. Invalid engine handle.
2023-09-25 16:12:16.906 desktop_platform_ch[27921:355518] Failed to send message to Flutter engine on channel 'webview_message/client_channel' (2).

This is my code

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

void main(List<String> args) async {
  WidgetsFlutterBinding.ensureInitialized();

  if (runWebViewTitleBarWidget(args)) {
    return;
  }

  runApp(const MyApp());
}

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

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

class WebView extends StatefulWidget {
  const WebView({super.key});

  @override
  State<WebView> createState() => _WebViewState();
}

class _WebViewState extends State<WebView> {
  @override
  void initState() {
    super.initState();
    // web();
  }

  void web() async {
    final webview = await WebviewWindow.create(
      configuration: const CreateConfiguration(title: "WebViewExample"),
    );
    webview.launch("https://www.google.com/");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Test'),
      ),
      body: ElevatedButton(onPressed: web, child: Text('Open')),
    );
  }
}

Reproduce Steps

Steps to reproduce the behavior:

  1. Copy and paste my code
  2. Click on the 'Open' button
  3. Look the debug console

Expected behavior

I need that when I click on the 'Open' button a new windows open with the webview.

Version (please complete the following information):

  • Flutter Version: 3.10.1 • channel stable
  • OS: MacBook Pro
  • plugin: desktop_webview_window

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with main.dart and the runWebViewTitleBarWidget entry point in title_bar.dart, then review the reported zone-mismatch and invalid-engine-handle errors. Reproduce the issue with Flutter 3.10.1 on macOS using the provided code and verify that clicking Open creates a usable webview window without the reported console errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.