WebKit + MaxGUI

BlitzMax Forums/Brucey's Modules/WebKit + MaxGUI

Brucey(Posted 2014) [#1]
I've added a new Linux HTMLView plugin which uses the WebKit renderer. It's probably easier to set it up than the other two for Gtk.

It's called bah.gtkwebkitgtk and available in SVN.

Seems to work quite well. Even plays the embedded youtube videos on the BlitzMax front page.
If you have any major gripes with it, let me know :-)


markcw(Posted 2014) [#2]
This is awesome! And no errors. Amazing...

Just had to install libwebkitgtk-dev

with dependencies
gir1.2-javascriptcoregtk-1.0
gir1.2-webkit-1.0
libjavascriptcoregtk-1.0-dev
libsoup2.4-dev


Brucey(Posted 2014) [#3]
No errors? That *is* amazing ;-)

Could maybe do with some better integration, as the basic functionality that HtmlView exposes in its API means you can't do much with it. Still it's better than nothing!


Actually I can't use this module on my work 64-bit Xubuntu box as it refuses to install the 32-bit libwebkitgtk on the 64-bit system.
But in all my other distros, it is working well.

Maybe a a 64-bit build of BlitzMax would get around this problem?


markcw(Posted 2014) [#4]
Oh, I don't know. I have 32-bit ubuntu 12.4 for BMax sake. I don't mind loosing out on the 64-bit feature, as it's just threads and extra processing speed, right?

Was looking at Purebasic yesterday and they have 64-bit versions for win/mac/linux.


Brucey(Posted 2014) [#5]
it's just threads and extra processing speed, right?

Threads you get on both.
Not sure about speed - possibly slower in some instances.
And access to more RAM.
And since platforms are "moving" to 64-bit, you'd imagine that one day 64-bit will be the only one available.


markcw(Posted 2014) [#6]
At a guess, I think a 64-bit BMax would take programming with FASM? Maybe Brl will get around to it some day...

I got gtkwebgtkhtml working by installing libgtkhtml3.14-dev
which adds 22 dependencies which I won't list since it's boring, the main one is libgail-dev

And it works but has issues. No css, not able to follow links with spaces and no navigation.
In gtkwebkitgtk you have all these, you can right-click and get a navigate menu which is really cool.

Then just out of interest I tried gtkwebmozilla which loads a blank window and gives this error on windowclose
(.createhtmlview.debug:3526): Gtk-CRITICAL **: IA__gtk_layout_move: assertion `child_widget->parent == GTK_WIDGET (layout)' failed

So I searched for a package that installed libgtkembedmoz.so and the only package now that has it (in ubuntu 12.4) is called kompozer - I couldn't find xulrunner. But it still didn't work so I tried adding ":/usr/lib/kompozer" to the MOZ_DIST_BIN path in gtkwebmozilla.bmx but still no luck. So I gave up. Is this one working for you Brucey?

Then I tried wxHtmlWindow which is pretty good, it has navigation (but no right-click menu) and links all work but no css again.

Then I tried wxWebview which doesn't run and gives this error
/usr/bin/ld: cannot find -lwx_gtk2u_webview-2.9

I tried installing libwxgtk2.8-dev but still the same. I have only got libwxgtk2.6 and libwxgtk2.8 in my package manager so I guess to get this working I would have to upgrade my distro again? Is there a way to regress this to 2.8?


markcw(Posted 2014) [#7]
On second thoughts, having just read your email, I think I'll have to update my distro. Again! Although looking up wx-common you need to go to ubuntu 14.4 trusty to get to wx 3.0 so I think I'll just content myself with gtkwebkitgtk for now actually.

Is there a feature in svn where I could get older copies of google code?


markcw(Posted 2014) [#8]
Sadly now I AM getting an error with webkit... a segmentation fault.:(

I thought it might be a dependency conflict so I uninstalled some packages I installed after I got webkit working but it still breaks/exits as soon as I load www.blitzmax.com so I ran gdb and it seems to be a flash bug/issue. But it's strange as it was working fine (I played an embedded flash video) and I haven't touched anything to do with flash.

Oh and flash works in firefox 28.0... no wait it's using html 5!

mark@mark-laptop:~/BlitzMax$ gdb maxide
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
...
Reading symbols from /home/mark/BlitzMax/maxide...(no debugging symbols found)...done.
(gdb) run
Starting program: /home/mark/BlitzMax/maxide 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[New Thread 0x5054b40 (LWP 5207)]
[New Thread 0x58e7b40 (LWP 5208)]
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
[New Thread 0x63bcb40 (LWP 5210)]
[New Thread 0x6cddb40 (LWP 5211)]
[New Thread 0x74deb40 (LWP 5212)]
[New Thread 0x7cfbb40 (LWP 5213)]
[New Thread 0xb77ffb40 (LWP 5214)]
[New Thread 0xb6ffeb40 (LWP 5215)]
[New Thread 0xb67fdb40 (LWP 5216)]
[New Thread 0xb5ffcb40 (LWP 5217)]
[New Thread 0xb57fbb40 (LWP 5218)]
[Thread 0xb6ffeb40 (LWP 5215) exited]
[Thread 0xb57fbb40 (LWP 5218) exited]
[Thread 0x74deb40 (LWP 5212) exited]
[New Thread 0x74deb40 (LWP 5219)]
[New Thread 0xb57fbb40 (LWP 5220)]
[New Thread 0xb6ffeb40 (LWP 5221)]
[New Thread 0xad8efb40 (LWP 5222)]
[New Thread 0xacfeeb40 (LWP 5223)]
[New Thread 0xac7edb40 (LWP 5224)]
[New Thread 0xab6f2b40 (LWP 5225)]
[Thread 0xb67fdb40 (LWP 5216) exited]
[Thread 0xb57fbb40 (LWP 5220) exited]
[Thread 0x74deb40 (LWP 5219) exited]
[New Thread 0x74deb40 (LWP 5230)]
[New Thread 0xb57fbb40 (LWP 5231)]
[Thread 0xad8efb40 (LWP 5222) exited]

Program received signal SIGSEGV, Segmentation fault.
0xb3baf9d7 in ?? () from /usr/lib/adobe-flashplugin/libflashplayer.so
(gdb) q
...



markcw(Posted 2014) [#9]
Working again! Ha. I removed the flash plugin and now it works.

adobe-flashplugin
+adobe-flash-properties-gtk

Must be a conflict between flash and html5.

Wierd how it worked for a while and then stopped.


Brucey(Posted 2014) [#10]
Flash is evil anyway;-)


markcw(Posted 2014) [#11]
Well now I browse Facebook I find some videos won't work without the flash. So I reinstalled flash and tried another package this time (flashplugin-installer) and it installs the same version 11.2 which is the same version on the adobe website and they say the last version for Linux.
http://get.adobe.com/flashplayer/

So that also breaks webkit (being the same thing)...

Funny how some videos will work without flash and some do. It's like it falls back to html5 with no flash but then html5 can't handle all videos.


markcw(Posted 2014) [#12]
Yes, sorry to find something wrong with this awesome module!

I might need to update my distro to fix this but it's something I can live with. All I want from an html renderer is docs with css support, so I can build maxide or the ce ide with Gtk. And this does the business!

I'm using Gtk maxide now and it's much nice than Fltk maxide (even with my Blitz.tff font in there). Monospace 10 (actually 14) looks fab and I can now triple-click to select a whole line in the code editor - which was a real pain in Fltk maxide. One issue is that the Open File dialog doesn't remember what folder you were in last, whereas this works in Fltk maxide.


Brucey(Posted 2014) [#13]
One issue is that the Open File dialog doesn't remember what folder you were in last, whereas this works in Fltk maxide.

Does the IDE tell it which folder it was in last? Otherwise, it may be a toolkit specific thing.


markcw(Posted 2014) [#14]
Yes, I think this is down to the IDE. For some reason in Fltk, RequestFile knows where the current path is but it shouldn't! You need to supply this with initial_path and that isn't done in maxide.bmx. I added my fix to the module tweaks board: http://www.blitzmax.com/Community/posts.php?topic=102332

Back on topic, I found out that flash does work with webkit in debug mode. It catches this error
** Message: console message:  @0: Unsafe JavaScript attempt to access frame with URL http://www.blitzmax.com/ from frame with URL 
http://www.youtube.com/embed/26T8KbdYqCg. Domains, protocols and ports must match.

[Answer: https://developer.linkedin.com/thread/2583]

For some reason when building maxide.debug it still exits though (ie. when I click on the blitzbasic.com link on the index page) maybe because webkit is in a container.


markcw(Posted 2014) [#15]
This is minor but...

clicking Example links in the docs opens an Html page instead of a code window.
Is it possible to fix (well it's not broken) but improve this feature? I loved that feature.

Also, Purebasic uses webkit in Linux too but they have disabled flash videos (black rectangle) probably because it was crashing the browser.


markcw(Posted 2014) [#16]
Well I have an example of the flash segfault bug. It only works in debug mode with the default createhtmlview example, but add any more code and it crashes (while still in debug). Just uncomment the "local test:int" line and it should crash. Not that this bug bothers me much I just wanted to know why it worked initially and then started crashing.
' createhtmlview.bmx

Strict

Framework bah.gtkmaxgui
Import bah.gtkwebkitgtk
Import brl.eventqueue
Import brl.basic
Import brl.blitz

Local window:TGadget
Local htmlview:TGadget
'Local test:Int

window=CreateWindow("My Window",30,20,600,440,,15|WINDOW_ACCEPTFILES)

htmlview=CreateHTMLView(0,0,ClientWidth(window),ClientHeight(window),window)
SetGadgetLayout htmlview,1,1,1,1

HtmlViewGo htmlview,"http://www.blitzmax.com/"

While WaitEvent()
	Print CurrentEvent.ToString()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend



markcw(Posted 2014) [#17]
Upgraded yesterday to ubuntu 12.10 quantal (which is very like precise) to see if upgrading webkitgtk from 10.8 to 10.10 would fix the segfault with flash but no it still crashes.


markcw(Posted 2014) [#18]
Is it possible to catch the url clicked (or current url) with webkit?


Brucey(Posted 2014) [#19]
Possibly. Does MaxGUI support that already, or are you looking for some new, webkit only, functionality?


markcw(Posted 2014) [#20]
I'm not sure if it is supported by Maxgui.

It's the example links in the help docs, they don't open a code window when maxide is using webkit. When you click, it just does nothing - I think before I upgraded my webkit the example links did open but in the browser, in html form. I just tried maxide using gtkhtml (libgtkhtml3.14-dev) and the example links do work ie. open a code window.

I can open bmx files from the sidebar/treeview using the "Modules Source" list. That's better than navigating manually with open file, but the quickest would be by clicking the example links.

Edit: forgot to mention you can select text, right-click and copy and paste to an untitled bmx file, which is pretty quick.


JoshK(Posted 2014) [#21]
Does anyone know how to get this working on 64-bit Ubuntu?