emacs-eaf / emacs-application-framework

EAF, an extensible framework that revolutionizes the graphical capabilities of Emacs
GNU General Public License v3.0
3.07k stars 233 forks source link

EAF browser fails to load org-roam-ui generated localhost page #788

Closed taquangtrung closed 2 years ago

taquangtrung commented 3 years ago

Describe the bug

EAF browser seems to hang when it tries to play a YouTube video. The webpage keeps flashing and couldn't play the video.

To Reproduce

(I captured this the behavior in the attached screenshot)

Expected behavior

EAF browser should be able to play video on YouTube

Versions (please complete the following info):

Error logs

Errors reported in the *eaf* buffer:

js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name
js: Uncaught (in promise) SyntaxError: Failed to execute 'whenDefined' on 'CustomElementRegistry': "style" is not a valid custom element name

Screenshots

emacs-eaf

MatthewZMD commented 3 years ago

I am not able to reproduce this issue.

taquangtrung commented 3 years ago

Thank you for the update!

I pull the newest code of eaf-browser (commit https://github.com/emacs-eaf/eaf-browser/commit/ca12e129fef67e4163e2f663278ad97d8d1e6a51), see that it indeed can play YouTube now.

Earlier, I tested with the older revision (commit https://github.com/emacs-eaf/eaf-browser/commit/629998c358fb3a59cb43e23e34d2567694e5e76e).

Maybe the new code has resolved this problem!

MatthewZMD commented 3 years ago

Awesome, glad it worked for you. Enjoy! 😄

taquangtrung commented 3 years ago

Thank you for the great EAF framework!

I also encountered a similar issue that eaf-browser cannot load a local webpage produced by org-roam-ui, not sure if I should open a new issue?

I just tested the newest eaf-browser but it seems that the problem with org-roam-ui still occurs. I tried to run eaf-open-browser with http://localhost:35901 but always obtain this error:

js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function
js: TypeError: Object.fromEntries is not a function

Here is the attached screenshot:

emacs-eaf-roam

MatthewZMD commented 3 years ago

Are you able to open this page in a regular browser?

taquangtrung commented 3 years ago

Yes, I can open it normally in Google Chrome.

MatthewZMD commented 3 years ago

If you open it in Google Chrome, press F12 and refresh, do you see the same errors?

taquangtrung commented 3 years ago

No, Google Chrome can open the locahost webservice http://localhost:35901 perfectly. I pull the newest EAF code and the error still occurs.

Here is the screenshot of Google Chrome:

emacs-roam-ui

MatthewZMD commented 3 years ago

Click on Console button in the devtools.

taquangtrung commented 3 years ago

Oh, there are several errors, but Chrome can still load the webpage:

emacs-roam-ui2

13thptr commented 3 years ago

Same issue here with (doom) Emacs 28.05 on WSL. Org-roam-ui opens fine in Firefox but not in EAF-browser. image Edit: By the way, Firefox gives no erros

MatthewZMD commented 3 years ago

Not a lot of clues at the moment. Do you have the EAF Browser ad-blocker turned off?

manateelazycat commented 3 years ago

Same issue here with (doom) Emacs 28.05 on WSL. Org-roam-ui opens fine in Firefox but not in EAF-browser. image Edit: By the way, Firefox gives no erros

I believe convert_index_html is works wrong with Windows that convert / with wrong char.

Can you replace load_index_html with below code in webengine.py:

    def load_index_html(self, app_file):
        self.buffer_widget.loadFinished.connect(self.init_app)

        self.index_file_dir = os.path.join(os.path.dirname(app_file), "dist")
        self.index_file = os.path.join(self.index_file_dir, "index.html")

        with open(self.index_file, "r") as f:
            html = self.convert_index_html(f.read(), self.index_file_dir)
            print(html)
            self.buffer_widget.setHtml(html, QUrl("file://"))

And paste content of *eaf* ?

13thptr commented 3 years ago

Same thing: js: TypeError: Object.fromEntries is not a function

manateelazycat commented 3 years ago

Same thing: js: TypeError: Object.fromEntries is not a function

Did you add print(html) ? I want to see html content that load in EAF browser. Please paste all content of *eaf* after add print(html) I need check whether something path wrong in html content.

13thptr commented 3 years ago

I did add this snippet. Is there anything more to do (apart from saving the file and maybe restarting Emacs ) ?

manateelazycat commented 3 years ago

I did add this snippet. Is there anything more to do (apart from saving the file and maybe restarting Emacs ) ?

Yes, restart Emacs

13thptr commented 3 years ago

I did, it didn't change anything.

manateelazycat commented 3 years ago

I didn't use org-roam, and haven't time try org-roam, no idea now, sorry.

MatthewZMD commented 3 years ago

I might try org-roam in the near future, I can have a look later.

13thptr commented 3 years ago

@manateelazycat No problem, thanks for your time @MatthewZMD That would be awesome.

manateelazycat commented 3 years ago

EAF not disable warning information that not print in Chrome console.

Print warning information not mean EAF browser have error that cause oram not working.

We should looks console print in EAF browser, not *eaf* buffer

tefkah commented 3 years ago

Hey, org-roam-ui guy here. The error that keeps popping up is probably due to the eaf browser not supporting the (Object.fromEntries)[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries] function. I could probably fix this by including some polyfill for that function or transpiling down to a lower version of ES.

What version of ES does the EAF browser officially support?

MatthewZMD commented 3 years ago

Hey, org-roam-ui guy here. The error that keeps popping up is probably due to the eaf browser not supporting the (Object.fromEntries)[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries] function. I could probably fix this by including some polyfill for that function or transpiling down to a lower version of ES.

What version of ES does the EAF browser officially support?

I just had a closer look, Object.fromEntries is supported at least on my system. Try M-i to open devtools in the EAF Browser and typing Object.fromEntries in the console should give the function definition:

> Object.fromEntries
ƒ fromEntries() { [native code] }

Are you able to see the same errors in devtools?

I'm wildly guessing it might have to do with node version, try this in terminal:

$ node
Welcome to Node.js v16.10.0.
Type ".help" for more information.
> Object.fromEntries
[Function: fromEntries]
manateelazycat commented 3 years ago

Hey, org-roam-ui guy here. The error that keeps popping up is probably due to the eaf browser not supporting the (Object.fromEntries)[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries] function. I could probably fix this by including some polyfill for that function or transpiling down to a lower version of ES.

What version of ES does the EAF browser officially support?

Can you give me some org-roam-ui JS code for test? Thanks

manateelazycat commented 2 years ago

2021-12-20 23-54-51 的屏幕截图

Today, after install org-roam and org-roam-ui, open http://localhost:35901/ , works well.

Please re-open this issue if you found some bug of EAF.

chana1024 commented 2 years ago
image

when update PyQtWebEngine to 15.5.5,"Object.fromEntries" was sloved.but i found the new problem

MatthewZMD commented 2 years ago

Click on the framework-xxx...js link in the devtools and see what it looks like in it.

chana1024 commented 2 years ago
image

pretty-print can't work,it maybe can't provide useful info.but i type " 'aa'.replaceAll('a','b') " in console,it show the webengine can't support replaceAll function. my webengine is 15.15.5