Fl4m3Ph03n1x

Fl4m3Ph03n1x

Background

I am using Elixir Desktop (by @dominicletz ) to make an elixir desktop application:

And I am successfully able to launch and manage my app. However, when I close it I always get this error:

[1224/050609.437:ERROR:window_impl.cc(115)] Failed to unregister class Chrome_WidgetWin_0. Error = 203

Animation

Problems

There are actually two issues here

  1. The application takes a very long time to close after I press Quit. The message is received by Phoenix (see the I AM LEAVING log) but for some reason the window takes several seconds to close.
  2. I get the previously mentioned error

Code

At this point 90% of this HelloWorld project is code generated by mix. There are only 2 files I changes that might be relevant here:

menubar.ex

defmodule WebInterface.MenuBar do
  @moduledoc """
    Menubar that is shown as part of the main Window on Windows/Linux. In
    MacOS this Menubar appears at the very top of the screen.
  """
  import WebInterface.Gettext
  use Desktop.Menu
  alias Desktop.Window

  @impl Desktop.Menu
  def render(assigns) do
    ~H"""
    <menubar>
      <menu label={gettext("File")}>
          <hr/>
          <item onclick="quit"><%= gettext "Quit" %></item>
      </menu>
      <menu label={gettext("Extra")}>
          <item onclick="browser"><%= gettext "Open Browser" %></item>
      </menu>
    </menubar>
    """
  end

  @impl Desktop.Menu
  def handle_event("quit", menu) do
    IO.puts("I AM LEAVING")
    Window.quit()
    {:noreply, menu}
  end

  def handle_event("browser", menu) do
    WebInterface.Endpoint.url()
    |> Window.prepare_url()
    |> :wx_misc.launchDefaultBrowser()

    {:noreply, menu}
  end

  @impl Desktop.Menu
  def mount(menu) do
    {:ok, menu}
  end

  @impl Desktop.Menu
  def handle_info(:changed, menu) do
    {:noreply, menu}
  end
end

applications.ex

defmodule WebInterface.Application do
  # See https://hexdocs.pm/elixir/Application.html
  # for more information on OTP Applications
  @moduledoc false

  use Application

    alias Desktop

  @impl true
  def start(_type, _args) do
    children = [
      WebInterface.Telemetry,
      {Phoenix.PubSub, name: WebInterface.PubSub},
      WebInterface.Endpoint,
      {Desktop.Window,
       [
         app: :web_interface,
         id: WebInterface,
         title: "Web Interface",
         size: {600, 500},
         menubar: WebInterface.MenuBar,
         url: &WebInterface.Endpoint.url/0
       ]}
    ]

    opts = [strategy: :one_for_one, name: WebInterface.Supervisor]
    Supervisor.start_link(children, opts)
  end

  @impl true
  def config_change(changed, _new, removed) do
    WebInterface.Endpoint.config_change(changed, removed)
    :ok
  end
end

I am hoping this error is caused by either a miss configuration or some function I am not implementing correctly.

How can I fix this error?

Showing Posts 1 to 8

dominicletz

dominicletz

Creator of Elixir Desktop

I’ve definitely seen this before but thought it to be something in my app. Thanks for this minimal example. I’ll have a look into this sometime next week

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

For convience’s sake, here is the MWE app:
https://github.com/Fl4m3Ph03n1x/market_manager/tree/remake

PS: I have added bakeware (GitHub - bake-bake-bake/bakeware: Compile Elixir applications into single, easily distributed executable binaries · GitHub) to the app. It is optional, but it replicates the issue in the exe file, so I think it can be a good point of reference as well.

And thank you for having a look at this!

The only thing I found was this old post for 2016:
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4759

Not sure what to do with it to be honest, specially when I don’t even have Chrome on my VM, I only use Firefox.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

@dominicletz Hey there, did you have some time to check the application out? If there is something I can do to help (that fits my limited ability within this domain) please do share!

dominicletz

dominicletz

Creator of Elixir Desktop

Well I did push an update to elixir-desktop that should cause the app now to instantly close. Please check that out and let me know if it works

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

Is it in the tag v1.4.0?

Or directly in the master branch ?

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

Hey I tested with master. I can confirm the application now closes faster, however there are still 2 issues:

ezgif.com-gif-maker

  1. If I go to File -> Quit, the application still get the error:
[0114/030715.062:ERROR:window_impl.cc(115)] Failed to unregister class Chrome_WidgetWin_0. Error = 0
  1. If I close the app by pressing the X on the top right corner I get a crash:
03:11:29.145 [notice] Application web_interface exited: shutdown
{"Kernel pid terminated",application_controller,"{application_terminated,web_interface,shutdown}"}
Kernel pid terminated (application_controller) ({application_terminated,web_interface,shutdown})

Crash dump is being written to: erl_crash.dump...done
[0114/031131.011:ERROR:window_impl.cc(115)] Failed to unregister class Chrome_WidgetWin_0. Error = 0

It could be because I am running in PROD, perhaps the crash happens due to a missconfig, but I have no data to support that.

Additionally, it looks like the process takes quite a time to exit. Not sure why.

dominicletz

dominicletz

Creator of Elixir Desktop

So in 1) it’s closing immediately but in 2) it just crashes? I’ll check what’s going on there.

Unfortunately the error message is coming directly from chrome https://bugs.chromium.org/p/chromium/issues/detail?id=113008 and is a know open issue. I don’t see an immediate way to get rid of it.

Fl4m3Ph03n1x

Fl4m3Ph03n1x OP

I feel there is nothing else o be done here. I will close this answer as your PR to master did fix the main issue.
Feel free to let me know when a new release is coming :smiley:

I have also just noticed that you now have it on hexpm !
Cool!

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews