Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mac] Can not show the UI when exec 'wails dev' #1504

Closed
cxt90730 opened this issue Jun 29, 2022 · 21 comments
Closed

[Mac] Can not show the UI when exec 'wails dev' #1504

cxt90730 opened this issue Jun 29, 2022 · 21 comments
Labels
Bug Something isn't working

Comments

@cxt90730
Copy link

Description

Can not show the UI when exec 'wails dev' (just an empty window), but web ui works. Also, the app created by 'wails build' works too.

To Reproduce

wails dev on my Mac(10.15 catalina)

Expected behaviour

the UI when exec 'wails dev' works

Screenshots

image

Attempted Fixes

No response

System Details

❯ wails doctor
Wails CLI v2.0.0-beta.38


Scanning system - Please wait (this may take a long time)...Done.

System
------
OS:		MacOS
Version: 	10.15.7
ID:		199506
Go Version:	go1.17.6
Platform:	darwin
Architecture:	amd64

Wails
------
Version: 	v2.0.0-beta.38

Dependency			Package Name	Status		Version
----------			------------	------		-------
xcode command line tools 	N/A		Installed	2373
npm 				N/A		Installed	8.0.0
*upx 				N/A		Available
*nsis 				N/A		Available

* - Optional Dependency

Diagnosis
---------
Your system is ready for Wails development!
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : Available at https://nsis.sourceforge.io/Download

Additional context

No response

@cxt90730 cxt90730 added the Bug Something isn't working label Jun 29, 2022
@stffabi
Copy link
Collaborator

stffabi commented Jun 29, 2022

Thanks for reporting this issue and using Wails.

Just a couple of questions to hopefully narrow down the problem.

  • Does it work with a clean Wails template? Like plain wails init -t plain -d test -n test or vanilla wails init -t vanilla -d test -n test
  • Do you see anything of interest in the "DevTools", could be opened by right clicking into the empty window and clicking "Inspect Element"?
  • Does the console output of wails dev show anything that is failing?

@cxt90730
Copy link
Author

thx, I need your help -_- :

  1. wails init -t plain -d test -n test works. But wails init -t vanilla -d test -n test not, also some mistakes happens: web ui shows myproject ui, whether the testproject ui. (Because of cache?)
  2. Only this:
<html><head></head><body></body></html>
<head></head>
<body></body>
<html><head></head><body></body></html>
  1. no fail output shows :(

@stffabi
Copy link
Collaborator

stffabi commented Jun 29, 2022

Thanks for your answers. Let's stick with the vanilla template case.

Can you please create again a new vanilla template in a new empty folder, just to make sure there's no mixed content. Also please make sure there's no other wails dev or npm running with your myproject UI.

When running wails dev in this new folder, could you please provide or try the following?

  • A screenshot of the "Network" tab of the dev tools from the Wails window.
  • A copy of the complete wails dev output.
  • What do you see when accessing http://localhost:3000 with your normal browser?
  • What do you see when accessing http://localhost:34115 with your normal browser?

@leaanthony
Copy link
Member

@leaanthony
Copy link
Member

Sounds like a vite error if plain works

@cxt90730
Copy link
Author

@stffabi @leaanthony Actually I used raw template vue. I executed these cmd:

$ mkdir wailstest
$ cd wailstest/
$ wails init -n myproject -t vue
$ cd myproject/
$ wails dev
Wails CLI v2.0.0-beta.38


Executing: go mod tidy -compat=1.17
Executing: wails generate module
Building application for development...
  - Installing frontend dependencies: Done.
  - Compiling frontend: Done.
  - Compiling application: Done.
  - Packaging application: Done.

Running frontend dev watcher command: 'npm run dev'
Watching (sub)/directory: /Users/cuixiaotian/wailstest/myproject
Using DevServer URL: http://localhost:34115
Using Frontend DevServer URL: http://localhost:3000
Using reload debounce setting of 100 milliseconds
INF | Serving assets from frontend DevServer URL: http://localhost:3000

> frontend@0.0.0 dev
> vite

Port 3000 is in use, trying another one...

  vite v2.9.13 dev server running at:

  > Local: http://localhost:3001/
  > Network: use `--host` to expose

  ready in 294ms.

9:13:23 PM [vite] hmr update /src/components/HelloWorld.vue
9:13:23 PM [vite] Internal server error: Failed to resolve import "../../wailsjs/go/main/App" from "src/components/HelloWorld.vue". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/cuixiaotian/wailstest/myproject/frontend/src/components/HelloWorld.vue
  1  |  import {reactive} from 'vue'
  2  |  import {Greet} from '../../wailsjs/go/main/App'
     |                       ^
  3  |
  4  |
      at formatError (/Users/cuixiaotian/wailstest/myproject/frontend/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:39055:46)
      at TransformContext.error (/Users/cuixiaotian/wailstest/myproject/frontend/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:39051:19)
      at normalizeUrl (/Users/cuixiaotian/wailstest/myproject/frontend/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:58329:26)
      at async TransformContext.transform (/Users/cuixiaotian/wailstest/myproject/frontend/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:58478:57)
      at async Object.transform (/Users/cuixiaotian/wailstest/myproject/frontend/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:39292:30)
      at async doTransform (/Users/cuixiaotian/wailstest/myproject/frontend/node_modules/vite/dist/node/chunks/dep-80fe9c6b.js:50012:29)
Added new directory to watcher: /Users/cuixiaotian/wailstest/myproject/frontend/wailsjs/go
DEB | [DevWebServer] Serving DevServer at http://localhost:34115
9:13:23 PM [vite] hmr update /src/components/HelloWorld.vue
DEB | [DevWebServer] Websocket client 0xc0000dcf30 connected

image

  • screen is blank
  • http://localhost:3000 is ok
  • http://localhost:34115 is my_own_object .... like the assets cached ?
    image

@stffabi
Copy link
Collaborator

stffabi commented Jun 29, 2022

Port 3000 is in use, trying another one...
vite v2.9.13 dev server running at:

Local: http://localhost:3001/

According to this it seems like you are still running something on that port, seems like your my_own_project.

Per default the vue template tries to use http://localhost:3000 to retrieve the content but vite is going to use :3001 to serve the content of the vue template, because :3000 is occupied. So please either stop your other webserver on port 3000 or change the "frontend:dev:serverUrl": http://localhost:3000" property in your wails.json of the newly created template. Then restart wails dev.

Could you please try again the tests above? You should now see the Wails template when browsing to http://localhost:34115 and also in the Wails Window.

@stffabi
Copy link
Collaborator

stffabi commented Jun 29, 2022

I suspect you might also be affected by issue #1358. Could you please also try this #1358 (comment) ?

@cxt90730
Copy link
Author

@stffabi emmm, the problem of http://localhost:34115 has been solved, because the process vite did not close (I don't know why...) and it binds port 3000. After kill it, port 34115 seems like ok now.
For your suggestion, I add config in build/darwin/Info.plist, and retry rm -rf build/bin && wails dev according to #1358 , but it also does not work... window still blank...

@cxt90730
Copy link
Author

@stffabi @leaanthony

<key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
            <key>NSExceptionDomains</key>
            <dict>
                <key>localhost</key>
                <dict>
                    <key>NSExceptionAllowsInsecureHTTPLoads</key>
                    <true/>
                    <key>NSIncludesSubdomains</key>
                    <true/>
                    <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                    <false/>
                </dict>
           </dict>
      </dict>

I add these config in build/darwin/Info.plist, and retry rm -rf build/bin && wails dev, it works now haha

@stffabi
Copy link
Collaborator

stffabi commented Jun 30, 2022

@cxt90730 awesome that it works now for you 👍

We would like to document this in a troubleshooting guide #1508 . It would be great to find the minimal settings needed to get it working, especially Apple has a "AllowLocalNetworking" flag. Would it be possible for you to give the following settings in your Info.plist a try, that would be awesome?

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsLocalNetworking</key>
    <true/>
</dict>

@cxt90730
Copy link
Author

@stffabi your settings works~~ 👍
Thank you very much for your patient guidance :)

@stffabi
Copy link
Collaborator

stffabi commented Jun 30, 2022

Awesome, thanks so much for testing the settings. So we could add those to the troubleshooting guide.

@csterritt
Copy link

I can confirm that the minimal fix above works with Vue3 and Vite. Thanks for the fix!

@cxt90730 cxt90730 closed this as completed Jul 6, 2022
@leaanthony leaanthony reopened this Jul 6, 2022
@robbles
Copy link

robbles commented Oct 5, 2022

Just ran into this, and the manual plist fix that's documented works!

However, I'm seeing it on macOS 11.4, which is currently only one version behind the latest. Shouldn't wails dev be including these settings by default? I'm guessing a majority of macOS devs trying wails for the first time are immediately running into this.

@leaanthony
Copy link
Member

Hi @robbles - I think there's an argument for that. How do you think it should work? Perhaps we could generate plist.info and info.dev.plist from the template, then wails dev copies the info.dev.plist version if it exists? This gives the developer to add in other dev related config. The only risk is that a production build would not have some of the fixes as now the developer has 2 files to manage. Thoughts?

@robbles
Copy link

robbles commented Oct 6, 2022

I have to admit, I'm not familiar enough with how these are generated.

But it seems like a reasonable solution. I think having an info.dev.plist is relatively intuitive and wouldn't be too hard to manage - having separate configs for dev and production is pretty common for other frameworks.

@leaanthony
Copy link
Member

Thanks for the feedback. Added a proposal in the linked issue

@leaanthony
Copy link
Member

@robbles - Please try the above PR to see if this fixes your problem. If you are unsure how to do this, please follow this guide. Let us know how you get on 👍

@robbles
Copy link

robbles commented Oct 20, 2022

Tried it out, and works perfectly! Thanks for fixing this, sorry about the delay in testing it.

@leaanthony
Copy link
Member

Awesome! Thanks for letting us know. This was a great suggestion. Here's a virtual beer 🍻 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants