Code Monkey home page Code Monkey logo

thdwb's Introduction

thdwb

This is the hotdog web browser project. It's a web browser with its own layout and rendering engine, parsers, and UI toolkit!

It's made from scratch entirely in golang. External dependencies are only OpenGL and GLFW, even go dependencies are kept to a minimum.

The main goal of this project is to learn how web browsers work under the hood by implementing one. The browser is far from stable, spec-compliant, or even really useful, but, I'm slowly working on bringing more features and supporting more sites.

🌭🌭🌭

Components

  • ketchup (html parser and DOM Tree builder)
  • mayo (css parser and Render Tree builder)
  • mustard (UI Toolkit, events and OpenGL)
  • sauce (requests, cache and filesystem)
  • bun (css layout calculator)
  • gg (drawing routines and text rendering)

Getting started

  • Running

    make

    This command will start the browser and load an example page

  • Testing

    make test

    This command will run all the configurated unit tests

  • Building

    make build

    This command will build the binary version

Screenshots

thdwb's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thdwb's Issues

can't build

elrut@linuzzzz:~/thdwb$ make
assets/icons.go:3:8: package embed is not in GOROOT (/usr/lib/go-1.15/src/embed) make: *** [Makefile:11: run] Error 1

Cannot build

thdwb $
 make
go: downloading github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb
go: downloading github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff
go: downloading github.com/go-gl/gl v0.0.0-20210501111010-69f74958bac0
go: downloading golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1
go: downloading golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb

command-line-arguments

/usr/bin/ld: $WORK/b001/pkg2.a(_x004.o): undefined reference to symbol 'pthread_key_delete@@GLIBC_2.2.5'
/usr/bin/ld: /usr/lib/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: run] Error 2

Epileptic bug on MacOS

I cloned your project and run make and I was left with this epileptic bug :

Apr-20-2021 12-23-23

Maybe this has something to do with high DPI screens ?

Commit I used : 532f88c

System info :

image

List Dependencies

Could you update this project to include its dependencies?
Every time I try to build it, it tells me I'm missing something,
I have to look up what the name of the package that includes that header is,
which often times isn't even helpful, install something,
and then get a totally new dependency error.
I don't know what cannot find -lXxf86vm is even supposed to mean,
and nowhere in the repo does it say that this depends on
a tonne of packages including xorg-dev, libx11-dev, libgl1-mesa-dev, and libxcursor-dev.
What do I actually need to install and build this project?

makefile does not use go modules

Building THDWB - ����
mustard/app.go:4:2: cannot find package "github.com/go-gl/gl/v4.1-core/gl" in any of:
	/usr/lib/go/src/github.com/go-gl/gl/v4.1-core/gl (from $GOROOT)
	/home/merith/.go/src/github.com/go-gl/gl/v4.1-core/gl (from $GOPATH)
mustard/button.go:5:2: cannot find package "github.com/go-gl/glfw/v3.3/glfw" in any of:
	/usr/lib/go/src/github.com/go-gl/glfw/v3.3/glfw (from $GOROOT)
	/home/merith/.go/src/github.com/go-gl/glfw/v3.3/glfw (from $GOPATH)
gg/context.go:14:2: cannot find package "github.com/golang/freetype/raster" in any of:
	/usr/lib/go/src/github.com/golang/freetype/raster (from $GOROOT)
	/home/merith/.go/src/github.com/golang/freetype/raster (from $GOPATH)
gg/util.go:16:2: cannot find package "github.com/golang/freetype/truetype" in any of:
	/usr/lib/go/src/github.com/golang/freetype/truetype (from $GOROOT)
	/home/merith/.go/src/github.com/golang/freetype/truetype (from $GOPATH)
gg/context.go:15:2: cannot find package "golang.org/x/image/draw" in any of:
	/usr/lib/go/src/golang.org/x/image/draw (from $GOROOT)
	/home/merith/.go/src/golang.org/x/image/draw (from $GOPATH)
gg/context.go:16:2: cannot find package "golang.org/x/image/font" in any of:
	/usr/lib/go/src/golang.org/x/image/font (from $GOROOT)
	/home/merith/.go/src/golang.org/x/image/font (from $GOPATH)
gg/context.go:17:2: cannot find package "golang.org/x/image/font/basicfont" in any of:
	/usr/lib/go/src/golang.org/x/image/font/basicfont (from $GOROOT)
	/home/merith/.go/src/golang.org/x/image/font/basicfont (from $GOPATH)
gg/context.go:18:2: cannot find package "golang.org/x/image/math/f64" in any of:
	/usr/lib/go/src/golang.org/x/image/math/f64 (from $GOROOT)
	/home/merith/.go/src/golang.org/x/image/math/f64 (from $GOPATH)
gg/path.go:7:2: cannot find package "golang.org/x/image/math/fixed" in any of:
	/usr/lib/go/src/golang.org/x/image/math/fixed (from $GOROOT)
	/home/merith/.go/src/golang.org/x/image/math/fixed (from $GOPATH)
make: *** [Makefile:15: build] Error 1

possible fix? use go modules to handle imports, makes it easier and will make it so make can autofetch the libs needed,

make test 报错老哥

Testing Sauce...

grep: Invalid range end

pkg-config --cflags -- gl gl

Package x11-xcb was not found in the pkg-config search path.
Perhaps you should add the directory containing `x11-xcb.pc'
to the PKG_CONFIG_PATH environment variable
Package 'x11-xcb', required by 'gl', not found
pkg-config: exit status 1

github.com/go-gl/glfw/v3.3/glfw

In file included from ../../../../go/pkg/mod/github.com/go-gl/glfw/v3.3/[email protected]/native_linbsd.go:10:0:
./glfw/include/GLFW/glfw3native.h:114:21: fatal error: GL/glx.h: No such file or directory
compilation terminated.
Makefile:23: recipe for target 'test' failed
make: *** [test] Error 2

and this happens when i try to do make test

can't load package: package sauce/go.mod: unknown import path "sauce/go.mod": cannot find module providing package sauce/go.mod
can't load package: package sauce/pages.go: unknown import path "sauce/pages.go": cannot find module providing package sauce/pages.go
can't load package: package sauce/sauce.go: unknown import path "sauce/sauce.go": cannot find module providing package sauce/sauce.go
can't load package: package sauce/sauce_test.go: unknown import path "sauce/sauce_test.go": cannot find module providing package sauce/sauce_test.go
make: *** [Makefile:24: test] Error 1

this is new

the another issues dont happened anymore before i did the things which nate send me but this one is different as i know

build command-line-arguments: cannot load embed: malformed module path "embed": missing dot in first path element
make: *** [Makefile:11: run] Error 1

img doesn't work with relative src url

eg, all the images are broken on:
http://evilpixie.scumways.com

The images on that page are all of the form <img src="img/blah.png" />. The lack of a leading slash confuses Hotdog.
It tries to load http://evilpixie.scumways.comimg/blah.png rather than http://evilpixie.scumways.com/img/blah.png.

assets are stale

I don't think the assets (icons) compile any more. No code generation occurs at compile time.
TODO: Fix by using embed fs:

//go:embed assetdir/*.html
//go:embed assetdir/*.png
var content embed.FS

the data bytes can then be read using

data, _ := content.ReadFile(name)

convert callers, hardcode string resource names instead of public funcs

Assets error when running `make`

# github.com/danfragoso/thdwb/mustard ../go/src/github.com/danfragoso/thdwb/mustard/tree.go:18:30: undefined: assets.DownChevron ../go/src/github.com/danfragoso/thdwb/mustard/tree.go:19:31: undefined: assets.RightChevron Makefile:11: recipe for target 'run' failed make: *** [run] Error 2

Can't use thdwb as a Go library

By moving your code to the root of the repo, other developers can import your code as a module by simply adding import https://github.com/danfragoso/thdwb to their code. To decrease clutter, you can have a main directory and put all your files in your main package in it.

Edit: Also, in the go.mod file the module name needs to be "github.com/danfragoso/thdwb"
Edit 2: I just noticed that you have other mustard and ketchup repos on GitHub. Perhaps you can do the same thing for them instead of hosting multiple projects in this one.

[Mustard] Compositing step

Today there's no compositing at all on mustard, all the pixel data of the nodes are written directly to the window fb.
The problem with this is that there's no easy way to overlap things.
To fix this issue we need to add a fb to each mustard node, and then composite the node onto the window fb before the texture generation, with this we should be able to deprecate the "overlays" code.

Error creating shader on Windows11

Exception 0xc0000005 0x8 0x0 0x0
PC=0x0
signal arrived during external code execution

runtime.cgocall(0xab1c30, 0xc000109c28)
D:/go1.19.1/go1.19.1/src/runtime/cgocall.go:158 +0x4a fp=0xc000109c00 sp=0xc000109bc8 pc=0x704e8a
github.com/go-gl/gl/v3.2-core/gl._Cfunc_glowCreateShader(0x0, 0x8b31)
_cgo_gotypes.go:5527 +0x5a fp=0xc000109c28 sp=0xc000109c00 pc=0x88779a
github.com/go-gl/gl/v3.2-core/gl.CreateShader(...)
C:/Users/15306/go/pkg/mod/github.com/go-gl/[email protected]/v3.2-core/gl/package.go:9310
github.com/danfragoso/thdwb/mustard.compileShader({0xbe664c, 0x9b}, 0x761e07?)
C:/Users/15306/Desktop/thdwb/mustard/shaders.go:39 +0x4a fp=0xc000109cd0 sp=0xc000109c28 pc=0x8a522a
github.com/danfragoso/thdwb/mustard.createNewGLProgram({0xbe664c?, 0xacef30?}, {0xbe65bb, 0x91})
C:/Users/15306/Desktop/thdwb/mustard/gl.go:21 +0x3a fp=0xc000109d58 sp=0xc000109cd0 pc=0x8a30fa
github.com/danfragoso/thdwb/mustard.createGLBackend()
C:/Users/15306/Desktop/thdwb/mustard/gl.go:56 +0x45 fp=0xc000109de8 sp=0xc000109d58 pc=0x8a34e5
github.com/danfragoso/thdwb/mustard.CreateNewWindow({0xbc1036, 0x5}, 0x384, 0x258, 0x1)
C:/Users/15306/Desktop/thdwb/mustard/window.go:52 +0x29d fp=0xc000109e78 sp=0xc000109de8 pc=0x8a825d
main.main()
C:/Users/15306/Desktop/thdwb/browser/main.go:46 +0x2c7 fp=0xc000109f80 sp=0xc000109e78 pc=0xaabc27
runtime.main()
D:/go1.19.1/go1.19.1/src/runtime/proc.go:250 +0x1fe fp=0xc000109fe0 sp=0xc000109f80 pc=0x73c01e
runtime.goexit()
D:/go1.19.1/go1.19.1/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000109fe8 sp=0xc000109fe0 pc=0x766f61

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:363 +0xd6 fp=0xc000047fb0 sp=0xc000047f90 pc=0x73c3b6
runtime.goparkunlock(...)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:369
runtime.forcegchelper()
D:/go1.19.1/go1.19.1/src/runtime/proc.go:302 +0xb1 fp=0xc000047fe0 sp=0xc000047fb0 pc=0x73c251
runtime.goexit()
D:/go1.19.1/go1.19.1/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000047fe8 sp=0xc000047fe0 pc=0x766f61
created by runtime.init.6
D:/go1.19.1/go1.19.1/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:363 +0xd6 fp=0xc000049f90 sp=0xc000049f70 pc=0x73c3b6
runtime.goparkunlock(...)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
D:/go1.19.1/go1.19.1/src/runtime/mgcsweep.go:278 +0x8e fp=0xc000049fc8 sp=0xc000049f90 pc=0x7267ee
runtime.gcenable.func1()
D:/go1.19.1/go1.19.1/src/runtime/mgc.go:178 +0x26 fp=0xc000049fe0 sp=0xc000049fc8 pc=0x71b386
runtime.goexit()
D:/go1.19.1/go1.19.1/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000049fe8 sp=0xc000049fe0 pc=0x766f61
created by runtime.gcenable
D:/go1.19.1/go1.19.1/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000012620?, 0xc7ab18?, 0x1?, 0x0?, 0x0?)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:363 +0xd6 fp=0xc000059f70 sp=0xc000059f50 pc=0x73c3b6
runtime.goparkunlock(...)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:369
runtime.(*scavengerState).park(0xf4e3a0)
D:/go1.19.1/go1.19.1/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc000059fa0 sp=0xc000059f70 pc=0x724873
runtime.bgscavenge(0x0?)
D:/go1.19.1/go1.19.1/src/runtime/mgcscavenge.go:617 +0x45 fp=0xc000059fc8 sp=0xc000059fa0 pc=0x724e65
runtime.gcenable.func2()
D:/go1.19.1/go1.19.1/src/runtime/mgc.go:179 +0x26 fp=0xc000059fe0 sp=0xc000059fc8 pc=0x71b326
runtime.goexit()
D:/go1.19.1/go1.19.1/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000059fe8 sp=0xc000059fe0 pc=0x766f61
created by runtime.gcenable
D:/go1.19.1/go1.19.1/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0xf4ea00?, 0xc000044ea0?, 0x0?, 0x0?, 0xc00004bf70?)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:363 +0xd6 fp=0xc00004be28 sp=0xc00004be08 pc=0x73c3b6
runtime.goparkunlock(...)
D:/go1.19.1/go1.19.1/src/runtime/proc.go:369
runtime.runfinq()
D:/go1.19.1/go1.19.1/src/runtime/mfinal.go:180 +0x10f fp=0xc00004bfe0 sp=0xc00004be28 pc=0x71a48f
runtime.goexit()
D:/go1.19.1/go1.19.1/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004bfe8 sp=0xc00004bfe0 pc=0x766f61
created by runtime.createfing
D:/go1.19.1/go1.19.1/src/runtime/mfinal.go:157 +0x45
rax 0xc00010a000
rbx 0xc000109c28
rcx 0x8b31
rdi 0xc00010a000
rsi 0xf4e6a0
rbp 0xc000109bf0
rsp 0x8ee89ff6a8
r8 0xf4ea00
r9 0x0
r10 0x146f
r11 0x7ffa5f620710
r12 0xc000109ca8
r13 0x140
r14 0xc000044000
r15 0x2030000
rip 0x0
rflags 0x10202
cs 0x33
fs 0x53
gs 0x2b

Can't Download/Install

Tried downloading as a ZIP file and it refuses to build, saying that it's not a valid repo and cannot find build:

root@MACHINE:/mnt/c/Users/USERNAME/Downloads/thdwb-master/zip/thdwb-master# make
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
# pkg-config --cflags  -- gl gl
pkg-config: exec: "pkg-config": executable file not found in $PATH
# github.com/go-gl/glfw/v3.3/glfw
cgo: exec gcc: exec: "gcc": executable file not found in $PATH
make: *** [Makefile:11: run] Error 2
root@MACHINE:/mnt/c/Users/USERNAME/Downloads/thdwb-master/zip/thdwb-master#

Made sure to grab a fresh install of make, pkg-config, and gcc, and it still refuses to build:

root@MACHINE:/mnt/c/Users/USERNAME/Downloads/thdwb-master/zip/thdwb-master# make
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
fatal: not a git repository (or any parent up to mount point /mnt)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
# github.com/go-gl/glfw/v3.3/glfw
In file included from ./glfw/src/internal.h:188,
                 from ./glfw/src/context.c:30,
                 from /root/go/pkg/mod/github.com/go-gl/glfw/v3.3/[email protected]/c_glfw.go:4:
./glfw/src/x11_platform.h:33:10: fatal error: X11/Xlib.h: No such file or directory
   33 | #include <X11/Xlib.h>
      |          ^~~~~~~~~~~~
compilation terminated.
# pkg-config --cflags  -- gl gl
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gl' found
Package gl was not found in the pkg-config search path.
Perhaps you should add the directory containing `gl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gl' found
pkg-config: exit status 1
make: *** [Makefile:11: run] Error 2

Tried downloading using Git and GH.exe CLI and it fails to even download every single time:

PS C:\Users\USERNAME\Downloads\thdwb-master> gh.exe repo clone danfragoso/thdwb
Cloning into 'thdwb'...
remote: Enumerating objects: 2143, done.
remote: Counting objects: 100% (44/44), done.
remote: Compressing objects: 100% (20/20), done.
error: RPC failed; curl 56 OpenSSL SSL_read: Connection was reset, errno 10054
error: 3527 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
exit status 128

support wayland windowing system on linux

I've forked the browser and added support for the modern wayland linux-based windowing system.
It now ships as the go-wayland-browser demo of my wayland repository.

What works:

  • buttons, icons
  • keyboard input including unicode
  • scrolling

What doesn't work yet:

  • popup menus, i intend to add these
  • input methods (virtual keyboards for CJK and emojis etc)
  • overlays - i don't know what it is

Differences:

  • there is no glfw anymore, so untested on windows os (however it might work using the windows compatibility in my lib)
  • no open gl dependency anymore, drawing via pure shm on cpu only (shared memory)
  • no shaders lol
  • compiles without cgo, so can use additional static analysis tools like go build race detector

The changes are confined to the mustard package. The changes to the browser package are minimal.

can you add sugar (javascript)?

Yeah, I know javascript is not going to last as a front end language of choice, since we can compile go to wasm, and also sugar tastes horrible on hot dogs, but hey, that's the world we live in currently. Answering "no" here is also a satisfactory answer for me here, just provide a list of reasons or whatever helps if someone really wants to do it.

can't build

make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • make build
  •   + CategoryInfo          : ObjectNotFound: (make:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

panic: runtime error: invalid memory address or nil pointer dereference

make
go: downloading github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff
go: downloading github.com/go-gl/gl v0.0.0-20210315015930-ae072cafe09d
go: downloading golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
go: downloading github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb
go: downloading golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5b7062]

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.(*Window).SetSizeLimits.func1(0x0, 0x12c, 0xc8, 0xffffffffffffffff, 0xffffffffffffffff)
	/home/data1/protected/go/pkg/mod/github.com/go-gl/glfw/v3.3/[email protected]/window.go:505 +0x22
github.com/go-gl/glfw/v3.3/glfw.(*Window).SetSizeLimits(0x0, 0x12c, 0xc8, 0xffffffffffffffff, 0xffffffffffffffff)
	/home/data1/protected/go/pkg/mod/github.com/go-gl/glfw/v3.3/[email protected]/window.go:505 +0x57
github.com/danfragoso/thdwb/mustard.CreateNewWindow(0x908822, 0x5, 0x384, 0x258, 0x1, 0x0)
	/home/data1/protected/Programming/git/thdwb/mustard/window.go:24 +0xba
main.main()
	/home/data1/protected/Programming/git/thdwb/browser/main.go:46 +0x2ed
exit status 2
make: *** [Makefile:11: run] Error 1
~/Programming/git/thdwb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.