Torque 3D Embedded Browser (WebKit)
by Josh Engebretson · in Torque 3D Professional · 01/15/2010 (8:55 pm) · 305 replies
Hey guys,
Here are some highlights:
1) It uses QtWebKit which is based off Apple's WebKit, the same HTML5/Canvas based web rendering engine from Chrome, Safari, Adobe AIR
2) QtWebKit is *easily* the best designed embeddable web browser I have found in exhaustive travels... (I actually compiled Chrome from source at one point, not recommended). Qt is *extremely* well supported and owned by Nokia who recently paid $153,000,000 for it. So, it is probably going to be around for some time.
3) Flash works :)
4) It is setup as a GuiControl so interacts perfectly with mouse events, control overlap, filters...
There are currently 3 rendering modes:

1) Render to Texture: This mode renders the web view to an offscreen buffer and then uploads it to a GFXTexHandle. It uses the Torque GUI system input for mouse and keyboard. As we're rendering to a texture, compositing and rendering to 3d surfaces is possible. Flash renders as long as it is set to windowless mode in the HTML (not a big deal). Instead of using Flash for anything other than presentation/video playback, I would suggest looking into Canvas/HTML5/CSS animations/effects in this mode.

2) Render Native: This mode integrates a native child window with Gui Control, giving the best of both worlds :) There is no need to render to texture as we're using an actual clipped child HWND which uses the Torque GUI system for position/extents and focus :) Transparency does not currently work, however under Vista/Win7 this should be possible. I should be able to get masking working with minimal effort, which would allow for shaped windows and transparent areas.

3) Render Popup: This mode pops up a standalone window, which is owned by the application and consistent in scripting with other modes. This is useful for things like integrated document browsing, tutorial video watching, game doc reading, game forum reading, etc... where you don't want to crowd your game interface with browser. However, you want CLOSE scripted integration with a standard browser (no worries of IE/Mozilla/Chrome), which isn't possible with the current "launch browser" functionality.
These modes work with HTTPS adding a nice way to authenticate to servers, secure purchasing, etc.
It is still pretty early in the development and the idea with the code release will be to get feedback on usability and features... especially WRT integration with Javascript on the page, etc.
EDIT: The first version has been released and is available HERE
Regards,
- Josh Engebretson
Mythos Labs, LLC
Here are some highlights:
1) It uses QtWebKit which is based off Apple's WebKit, the same HTML5/Canvas based web rendering engine from Chrome, Safari, Adobe AIR
2) QtWebKit is *easily* the best designed embeddable web browser I have found in exhaustive travels... (I actually compiled Chrome from source at one point, not recommended). Qt is *extremely* well supported and owned by Nokia who recently paid $153,000,000 for it. So, it is probably going to be around for some time.
3) Flash works :)
4) It is setup as a GuiControl so interacts perfectly with mouse events, control overlap, filters...
There are currently 3 rendering modes:

1) Render to Texture: This mode renders the web view to an offscreen buffer and then uploads it to a GFXTexHandle. It uses the Torque GUI system input for mouse and keyboard. As we're rendering to a texture, compositing and rendering to 3d surfaces is possible. Flash renders as long as it is set to windowless mode in the HTML (not a big deal). Instead of using Flash for anything other than presentation/video playback, I would suggest looking into Canvas/HTML5/CSS animations/effects in this mode.

2) Render Native: This mode integrates a native child window with Gui Control, giving the best of both worlds :) There is no need to render to texture as we're using an actual clipped child HWND which uses the Torque GUI system for position/extents and focus :) Transparency does not currently work, however under Vista/Win7 this should be possible. I should be able to get masking working with minimal effort, which would allow for shaped windows and transparent areas.

3) Render Popup: This mode pops up a standalone window, which is owned by the application and consistent in scripting with other modes. This is useful for things like integrated document browsing, tutorial video watching, game doc reading, game forum reading, etc... where you don't want to crowd your game interface with browser. However, you want CLOSE scripted integration with a standard browser (no worries of IE/Mozilla/Chrome), which isn't possible with the current "launch browser" functionality.
These modes work with HTTPS adding a nice way to authenticate to servers, secure purchasing, etc.
It is still pretty early in the development and the idea with the code release will be to get feedback on usability and features... especially WRT integration with Javascript on the page, etc.
EDIT: The first version has been released and is available HERE
Regards,
- Josh Engebretson
Mythos Labs, LLC
About the author
http://www.TheEngine.Co
#142
Have you tried running cleanShaders.bat as a first step? Looks like there's a lot of procedural shaders failing in there, including the one above.
02/02/2011 (11:17 am)
Quote:Material - WebCube_WebCube(6515) - Failed to load diffuse map art/shapes/webcube/#MyWebTexture2 for stage 0
GFXD3D9Shader::_compileShader - Error compiling shader: E_FAIL: An undetermined error occurred (80004005)
C:/Torque/Torque 3D 2009 Pro 1.1 Beta 3/Demos/WebKitDemo/game/shaders/procedural/a8513428bf719935_P.hlsl(71,4): error X3004:
Have you tried running cleanShaders.bat as a first step? Looks like there's a lot of procedural shaders failing in there, including the one above.
#143
cleanShaders.bat
DeleteCachedDTSs.bat
DeleteDSOs.bat
DeletePrefs.bat
... all results in the same thing. =( What am I missing?
Updated console log:
http://binarystars.com/download/webkit-console-02022011.log
02/02/2011 (7:04 pm)
Ted I gave your suggestion a try and ran:cleanShaders.bat
DeleteCachedDTSs.bat
DeleteDSOs.bat
DeletePrefs.bat
... all results in the same thing. =( What am I missing?
Updated console log:
http://binarystars.com/download/webkit-console-02022011.log
#144
02/02/2011 (7:15 pm)
@Alan: I'd say that there are some pretty severe issues with your project before even getting to the WebKit stuff. I don't see any loading or compile messages, so I don't know if any errors are occurring, but it looks like some stuff was ripped out of the project. Did you create the project as detailed here or is it modified?
#145
I suspect it is related to a faulty video card driver, but I was unable to confirm that. On my laptop (with an HD 5650), everything ran fine. On my desktop with an 8800 it crashed while the same pc with a 5870 (which has driver issues ever since it came out) had no problem whatsoever.
So indeed it could be something nastier that is not necessarily relatedto Torque code - more like Webkit or driver code.
02/02/2011 (7:38 pm)
It could also be an issue with certain video cards. While we had this compiled into our game, some of our testers reported crashes like those of Alan's. I suspect it is related to a faulty video card driver, but I was unable to confirm that. On my laptop (with an HD 5650), everything ran fine. On my desktop with an 8800 it crashed while the same pc with a 5870 (which has driver issues ever since it came out) had no problem whatsoever.
So indeed it could be something nastier that is not necessarily relatedto Torque code - more like Webkit or driver code.
#146
So I tried it without changes, nothing happened when I clicked a link. - not good
I copied the nppdf32.dll into the plugins directory i.e game/plugins click a link to a pdf. The screen goes a grey colour and I see a temp file in the game directory which is the pdf I want to view - better
I tried copying all the acrobat DLL"s into game/plugin - same result as above
Could this be due to the window/windowless issue with Flash that by forcing windowless it breaks other plugins
02/03/2011 (4:13 am)
Since flash seems to now work so well has anyone have any success getting the acrobat pdf plugin to load? It would be great for manuals and so onSo I tried it without changes, nothing happened when I clicked a link. - not good
I copied the nppdf32.dll into the plugins directory i.e game/plugins click a link to a pdf. The screen goes a grey colour and I see a temp file in the game directory which is the pdf I want to view - better
I tried copying all the acrobat DLL"s into game/plugin - same result as above
Could this be due to the window/windowless issue with Flash that by forcing windowless it breaks other plugins
#147
02/03/2011 (6:36 am)
@Alan: Did you create a new project in Beta 3, then move the webkit files over to the new project?
#148
02/03/2011 (7:34 am)
@Philip Thanks for asking... I'm actually still working on it. Let me get back to you.
#149
Here are the steps that I have followed in detail:
binarystars.com/download/torque3dwebkitfiles/WebKit-Instructions-01-2011.TXT
Console Log:
binarystars.com/download/torque3dwebkitfiles/console-02032011.log
Patches:
binarystars.com/download/torque3dwebkitfiles/konrad-patch1.diff
binarystars.com/download/torque3dwebkitfiles/konrad-patch2.diff
Specifications:
*Torque 3D Professional Beta 3
*Visual Studio 2008 SP1
*Qt 4.7.1 http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.1.zip
*Latest Video Drivers (in my instance it's NVidia Graphics Driver v266.58) http://www.nvidia.com
*PhysX System Software (inclued in my video driver installation - v9.10.0514)
*June10 DXSDK http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba
*PhysX SDK (optional - not available for me to get yet)
*Windows 7 Utimate x64 (in my example)
*gnuWin Packages:Patch for Windows http://gnuwin32.sourceforge.net/packages/patch.htm
*TeraCopy http://www.codesector.com/download.php
Methods I have tried so far:
*Blank Project Recompile - success no errors. Example Console: binarystars.com/download/torque3dwebkitfiles/blank-console.log
*Qt, Webkit + Josh + Konrad = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad + generateProjects.bat = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad + generateProjects.bat + cleanShaders.bat = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad + *.bat = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad on top of blank project = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad on top of blank project + generateProjects.bat = Success compile but no Play Demo.
*Will try another computer in a moment.
02/03/2011 (12:10 pm)
Same thing... sigh! I think I tried everything. Here are the steps that I have followed in detail:
binarystars.com/download/torque3dwebkitfiles/WebKit-Instructions-01-2011.TXT
Console Log:
binarystars.com/download/torque3dwebkitfiles/console-02032011.log
Patches:
binarystars.com/download/torque3dwebkitfiles/konrad-patch1.diff
binarystars.com/download/torque3dwebkitfiles/konrad-patch2.diff
Specifications:
*Torque 3D Professional Beta 3
*Visual Studio 2008 SP1
*Qt 4.7.1 http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.1.zip
*Latest Video Drivers (in my instance it's NVidia Graphics Driver v266.58) http://www.nvidia.com
*PhysX System Software (inclued in my video driver installation - v9.10.0514)
*June10 DXSDK http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba
*PhysX SDK (optional - not available for me to get yet)
*Windows 7 Utimate x64 (in my example)
*gnuWin Packages:Patch for Windows http://gnuwin32.sourceforge.net/packages/patch.htm
*TeraCopy http://www.codesector.com/download.php
Methods I have tried so far:
*Blank Project Recompile - success no errors. Example Console: binarystars.com/download/torque3dwebkitfiles/blank-console.log
*Qt, Webkit + Josh + Konrad = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad + generateProjects.bat = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad + generateProjects.bat + cleanShaders.bat = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad + *.bat = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad on top of blank project = Success compile but no Play Demo.
*Qt, Webkit + Josh + Konrad on top of blank project + generateProjects.bat = Success compile but no Play Demo.
*Will try another computer in a moment.
#150
binarystars.com/download/torque3dwebkitfiles/console-cpu2.txt
1. Packaged the kit as an installer.
2. On Second Computer, installed the program and did the directX update.
3. Copied over the QT bin files and set env path.
4. Program was successfully able to launch but after that the Play Demo fails.
02/03/2011 (12:35 pm)
Same thing with another computer:binarystars.com/download/torque3dwebkitfiles/console-cpu2.txt
1. Packaged the kit as an installer.
2. On Second Computer, installed the program and did the directX update.
3. Copied over the QT bin files and set env path.
4. Program was successfully able to launch but after that the Play Demo fails.
#151
@Philip Any other suggestions I could try? Or is it really a lost cause for now lol...
02/05/2011 (6:51 am)
Update: I went back to see if there was something stupid on my part...and was successfully able to get the webkit to work in Torque 3D Beta 1 without any problems. @Philip Any other suggestions I could try? Or is it really a lost cause for now lol...
#152
"%guiContent = new MyGameTSCtrl(PlayGui)"
I originally got the webkit to work in Beta 1.
* I followed all the steps from the webkit instructions from Josh to get it to work.
For Beta 3,
1. I ported all the code over from Beta 1.
2. I used Konrad's code in order for it to work in Beta 3.
3. I added my own code (Look at comments #139 and #140 in this thread).
4. I am using QT library 4.7.1 instead of 4.6.2.
5. I followed the directions from the webkit to modify the QT 4.7.1 files, then I compiled the QT 4.7.1 library through a Visual Studio command prompt, and then I typed in "nmake" in the command prompt after compiling the library.
6. Don't forget to add the QT stuff to your project.conf file, located in BuildFiles/config.
7. Make sure you change all references from 4.6.2 to 4.7.1. (if you are using 4.7.1)
8. Make sure all your project settings in visual studio are correct.
I'll try to think of anything else I am may have done to get it to work, but that is all I can think of right now.
Make sure you are not missing anything from Beta 1.
02/05/2011 (11:15 am)
Are you using the MyGameTSCtrl class in the game/art/gui/playGui.gui as shown below?"%guiContent = new MyGameTSCtrl(PlayGui)"
I originally got the webkit to work in Beta 1.
* I followed all the steps from the webkit instructions from Josh to get it to work.
For Beta 3,
1. I ported all the code over from Beta 1.
2. I used Konrad's code in order for it to work in Beta 3.
3. I added my own code (Look at comments #139 and #140 in this thread).
4. I am using QT library 4.7.1 instead of 4.6.2.
5. I followed the directions from the webkit to modify the QT 4.7.1 files, then I compiled the QT 4.7.1 library through a Visual Studio command prompt, and then I typed in "nmake" in the command prompt after compiling the library.
6. Don't forget to add the QT stuff to your project.conf file, located in BuildFiles/config.
7. Make sure you change all references from 4.6.2 to 4.7.1. (if you are using 4.7.1)
8. Make sure all your project settings in visual studio are correct.
I'll try to think of anything else I am may have done to get it to work, but that is all I can think of right now.
Make sure you are not missing anything from Beta 1.
#153
02/05/2011 (12:23 pm)
Also, when I created a new project, I created a "Full" build, not an "Empty" build.
#154
This fixed the problem I was having where all the images on my web sites using webkit were blue question marks.
02/05/2011 (12:55 pm)
@Alan: I also copied all the folders from "C:\Qt\QtCustom4.7.1\plugins" to my "game\plugins" folder.This fixed the problem I was having where all the images on my web sites using webkit were blue question marks.
#155
02/06/2011 (5:42 am)
How are you porting code from beta 1? ... Webkit and Sdk? Beyond that step I think I understand what to do.
#156
02/06/2011 (9:39 am)
I'm just porting the webkit classes created by Josh, including the MyGameTSCtrl class. Just the usual.
#157
"GFXD3D9Shader::_compileShader - Error compiling shader: E_FAIL: An undetermined error occurred (80004005)
c:/Torque/Torque 3D 2009 Pro 1.1 Beta 3/Demos/webkitblank/game/shaders/procedural/ed0418f6fc867c4a_P.hlsl(83,4): error X3004: undeclared identifier 'fizzle'"
I am not getting any of these errors in my console.log.
If you create a project without the webkit, do you get these same errors in your console.log file?
I know that the "ProcessedShaderMaterial::setTextureStages" function is called for the webkit textures. In this function, the following line of code is called:
"texObject = texTarget->getTexture();"
This line of code calls the "virtual GFXTextureObject* getTexture( U32 mrtIndex = 0 ) const { return mCtrl->getTexture(); }" function in the "WebTextureMap" class that we use for the webkit.
My point is if you are having all these shader errors in your console.log file, then maybe you need to figure out what is causing these errors.
The shader errors I see in your console.log file are not just for the webcubes but for your generic shaders as well.
Maybe if you fix these shader errors, then the webkit will work because it sounds like you have all the webkit stuff setup correctly.
02/06/2011 (12:51 pm)
@Alan: You are getting the following types of errors in your console.log file:"GFXD3D9Shader::_compileShader - Error compiling shader: E_FAIL: An undetermined error occurred (80004005)
c:/Torque/Torque 3D 2009 Pro 1.1 Beta 3/Demos/webkitblank/game/shaders/procedural/ed0418f6fc867c4a_P.hlsl(83,4): error X3004: undeclared identifier 'fizzle'"
I am not getting any of these errors in my console.log.
If you create a project without the webkit, do you get these same errors in your console.log file?
I know that the "ProcessedShaderMaterial::setTextureStages" function is called for the webkit textures. In this function, the following line of code is called:
"texObject = texTarget->getTexture();"
This line of code calls the "virtual GFXTextureObject* getTexture( U32 mrtIndex = 0 ) const { return mCtrl->getTexture(); }" function in the "WebTextureMap" class that we use for the webkit.
My point is if you are having all these shader errors in your console.log file, then maybe you need to figure out what is causing these errors.
The shader errors I see in your console.log file are not just for the webcubes but for your generic shaders as well.
Maybe if you fix these shader errors, then the webkit will work because it sounds like you have all the webkit stuff setup correctly.
#158
www.garagegames.com/community/forums/viewthread/119225
At the bottom of this thread, Scott Burns from Garage Games says,
"... The key of the issue here seems to be having AA set to anything higher than 2 while AL is turned on and changing resolutions. It's also definitely specific to Nvidia cards in general.
Bug confirmed."
This is a bug identified in T3D 1.1 Beta 2. Maybe that is why your webkit works in Beta 1, but not Beta 3.
02/06/2011 (1:06 pm)
Look at the following thread. I don't know if this will help.www.garagegames.com/community/forums/viewthread/119225
At the bottom of this thread, Scott Burns from Garage Games says,
"... The key of the issue here seems to be having AA set to anything higher than 2 while AL is turned on and changing resolutions. It's also definitely specific to Nvidia cards in general.
Bug confirmed."
This is a bug identified in T3D 1.1 Beta 2. Maybe that is why your webkit works in Beta 1, but not Beta 3.
#159
Have successfully built QT and the resulting LIB and DLL files are there in the QT\4.7.1\bin and \lib folders. Have added \bin to my PATH variable and the \lib folder has been added to my VS "libraries" folders so they can be found.
Am now moving on to attempt to build the webkitdemo solution, hopefully it will work. I have made all the required changes from Konrad and yourself to have it work in Beta 3.
One question - if this all works OK, and I want to distribute the browser with my game (am just working in the webkitdemo right now, when I get that running I will then move on to integrating this into my own product), which files do I need to include in my \game folder when building the installer, and would there be any additional steps required by the client to enable the in-game browser? I seem to remember reading that they might have to install Safari and a compatible Flash client in order for Flash to work in-game?
Many thanks for all the info, this is going to be very useful to us, when we actually get it working :)
02/17/2011 (8:24 am)
Hey Philip,Have successfully built QT and the resulting LIB and DLL files are there in the QT\4.7.1\bin and \lib folders. Have added \bin to my PATH variable and the \lib folder has been added to my VS "libraries" folders so they can be found.
Am now moving on to attempt to build the webkitdemo solution, hopefully it will work. I have made all the required changes from Konrad and yourself to have it work in Beta 3.
One question - if this all works OK, and I want to distribute the browser with my game (am just working in the webkitdemo right now, when I get that running I will then move on to integrating this into my own product), which files do I need to include in my \game folder when building the installer, and would there be any additional steps required by the client to enable the in-game browser? I seem to remember reading that they might have to install Safari and a compatible Flash client in order for Flash to work in-game?
Many thanks for all the info, this is going to be very useful to us, when we actually get it working :)
#160
We now have websites showing up on the sample cubes which is great... And Flash even worked on its own, guess latest Firefox with latest Flash was already enough on my PC to support it.
Seems all that is required to make this portable is to copy 4 QT DLLs into the game folder along with plugins from QT 4.7.1. All images are displaying correctly on pages, and Flash sites animate.
However, for some reason, I am unable to actually navigate any pages... Seems clicking is not working at all. Everything else seems correct, and if I use the browser gui everything works properly - can click anything and stop and start Flash videos, etc.
Kind of driving me crazy to be this close, anybody have any ideas?
02/17/2011 (10:49 pm)
Up and running, well almost...We now have websites showing up on the sample cubes which is great... And Flash even worked on its own, guess latest Firefox with latest Flash was already enough on my PC to support it.
Seems all that is required to make this portable is to copy 4 QT DLLs into the game folder along with plugins from QT 4.7.1. All images are displaying correctly on pages, and Flash sites animate.
However, for some reason, I am unable to actually navigate any pages... Seems clicking is not working at all. Everything else seems correct, and if I use the browser gui everything works properly - can click anything and stop and start Flash videos, etc.
Kind of driving me crazy to be this close, anybody have any ideas?
Torque 3D Owner Alan A. Currie
How did you get yours to work exactly?
Torsion Log:
http://binarystars.com/download/torsion-webkit-02022011_log.txt
-al