about summary refs log tree commit diff stats
path: root/src/loader
Commit message (Collapse)AuthorAgeFilesLines
* twtstr: misc refactoringsbptato2024-10-011-1/+1
|
* loader: add missing nil check in openCachedItembptato2024-10-011-1/+4
| | | | also, erase cacheRef when it couldn't be opened
* loader: get rid of a pointless tablebptato2024-09-281-18/+26
|
* loader: send headers for tocache requests toobptato2024-09-283-37/+38
| | | | | This lets us send the transparency bit as a header, and also halves the number of header parsers in loader.
* gopher: do not depend on libcurlbptato2024-09-281-0/+6
| | | | | | | | I'm thinking of making libcurl entirely optional; let's start with the easiest part. I've added a SOCKS5 client for ALL_PROXY support; I know curl supported others too, but whatever.
* loader: clean up connecterrorbptato2024-09-282-56/+87
| | | | | | * allow string values for public errors * remove unused errors * update naming
* Fixes for FreeBSDbptato2024-09-261-1/+1
|
* loader, pager: fix fd leaksbptato2024-09-251-0/+2
|
* Replace std/selectors with pollbptato2024-09-231-44/+19
| | | | | | | | | | | | std/selectors uses OS-specific selector APIs, which sounds good in theory (faster than poll!), but sucks for portability in practice. Sure, you can fix portability bugs, but who knows how many there are on untested platforms... poll is standard, so if it works on one computer it should work on all other ones. (I hope.) As a bonus, I rewrote the timeout API for poll, which incidentally fixes setTimeout across forks. Also, SIGWINCH should now work on all platforms (as we self-pipe instead of signalfd/kqueue magic).
* client, forkserver, dynstream: misc refactorings, fixesbptato2024-09-233-13/+19
| | | | | | * fix broken int conversion in dynstream * fix EPIPE handling in forkserver * merge fdmap and connectingContainers into loader map
* loader: mmap intermediate image files, misc refactoringbptato2024-09-225-57/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor parseHeader * optimize response blob() * add direct "to cache" mode for loader requests which sets stdout to a file, and use it for image processing * move image resizing into a separate process * mmap cache files in between processing steps when possible At last, resize is no longer a part of image decoding. Also, it feels much nicer to keep encoded image data in the same cache as everything else. The mmap operations *should* be more efficient than copying the whole RGBA data through a pipe. In practice, it only makes a difference for loading (well, now just mmapping) the encoded image into the pager, where it singlehandedly speeds up image display by 10x on my test image. For the other steps, the unfortunate fact that "tocache" must delay the next fork/exec in the pipeline until the entire image is processed seems to equal out any wins we might have gotten from skipping a single raw RGBA copy. I have tried moving the delay before the exec (it's possible with yet another pipe), but it didn't help much and made the code much uglier. (Not that tocache didn't, but I can live with this...)
* loader: fix rbtCache racebptato2024-09-153-36/+49
| | | | | | | | | | | | | | | I thought this would work fine, but then images weren't loading. Upon closer inspection I realized we don't necessarily let the image decoder finish reading the entire file on pass 1 (header parsing), which means pass 2 (decoding) can end up reading a partially downloaded cache file. To fix this, we now fall back to streaming mode when an open handle to the cached item still exists. (An alternative would be to wait for the cached item to finish loading, but that's harder to implement and might be slower anyway - the current implementation allows for the decoder to run while an image is still being loaded, but we couldn't do that with the second approach.)
* loader: refactor/move around some procsbptato2024-09-153-732/+746
| | | | | | | | | | | | | | Module boundaries didn't make much sense here either. Specifically: * loader/cgi was originally just one of the many "real" protocols supported by loader, so it was in a separate module (like the other ones). Now it's mostly an "internal" protocol, and it was getting cumbersome to pass all required loader state to loadCGI. * The loader interface has grown quite large, but there is no need for (or advantage in) putting it in the same module as the implementation. Now CGI is handled by loader, and the interface is in the new module "loaderiface".
* loader: improve map interfacebptato2024-09-141-3/+8
| | | | directly accessing map was a bit too error prone
* loader: refactor, misc optimizations & fixesbptato2024-09-144-176/+270
| | | | | | | | * factor out input/output handle tables; use a seq instead * add possibility to directly open cached items onto stdin (mainly an optimization for reading images, which are always cached) * close used handles on local CGI execution * make clone during load work again
* loader, client, buffer: use selectInto (not select)bptato2024-09-031-3/+4
| | | | select allocates. (makes sense, but I never realized...)
* loader: fix crashes with kqueue backendbptato2024-09-032-4/+23
| | | | | | | pain... (also, fix an fd leak, plus a more general bug where we registered empty output handles.)
* loader: fix some fd leaksbptato2024-09-022-7/+26
| | | | + be a bit more paranoid about double closes
* canvas: make sure we don't link to QJSbptato2024-09-011-0/+20
|
* canvas: move to separate CGI scriptbptato2024-09-012-53/+13
| | | | | | | | | | * stream: and passFd is now client-based, and accessible for buffers * Bitmap's width & height is now int, not uint64 * no more non-network Bitmap special case in the pager for canvas I just shoehorned it into the static image model, so it still doesn't render changes after page load. But at least now it doesn't crash the browser.
* loader: fix crash on empty data URLsbptato2024-08-171-1/+8
|
* dom, xhr: slight progress on modules, fix an XHR bugbptato2024-08-151-0/+5
| | | | | | * actually download & compile modules (but don't run them yet) * fix a bug in XHR (on some older Nim versions, move() doesn't actually move)
* xhr: more progressbptato2024-08-152-7/+8
| | | | | | | | | | * add responseText, response * add net tests -> currently sync XHR only; should find a way to do async tests... * update monoucha -> simplified & updated some related code that no longer worked properly
* xhr: progressbptato2024-08-133-44/+90
| | | | | | | | | | | | | * fix header case sensitivity issues -> probably still wrong as it discards the original casing. better than nothing, anyway * fix fulfill on generic promises * support standard open() async parameter weirdness * refactor loader response body reading (so bodyRead is no longer mandatory) * actually read response body still missing: response body getters
* dom: fix crash on wrong image content typebptato2024-08-111-3/+2
| | | | + slightly optimize getContentType
* Update monouchabptato2024-08-093-90/+82
|
* loader: move back data URL handlingbptato2024-08-032-5/+50
| | | | | | | data URIs can get megabytes long; however, you can only stuff so many bytes into the envp. (This was thwarting my efforts to view pandoc- generated standalone HTML in Chawan.) So put `data:' back into the loader process.
* Fixes for Nim 2.2bptato2024-07-294-6/+1
| | | | | | | | | * xmlhttprequest: fix missing import * painter: generic tuple workaround * dynstream: merge module with implementations (so it will work with vtables) Not enabling vtables yet since it doesn't work with refc.
* headers, request: bring it closer to the standardbptato2024-07-273-118/+215
| | | | | | * add standard interfaces to headers * use window base URL for newRequest * remove pointless generic in newRequest
* loader: follow redirects in fetch()bptato2024-07-271-4/+21
|
* loader: fix saveToBitmap for 0-len imagesbptato2024-07-271-1/+5
|
* loader: copy cached items on buffer cloningbptato2024-07-201-2/+11
| | | | | This fixes a bug where cloning buffers with images would crash the browser.
* loader: async status/headers for fetchbptato2024-07-192-23/+39
| | | | | | | | The status code & headers are no longer guaranteed to be sent right after res/outputId, so read them asynchronously instead. (This is pretty much the same code as the buffer connection handler in pager. Hopefully we can merge the two at some point.)
* html: event cleanup, XHR progressbptato2024-07-182-12/+62
|
* 32-bit compilation fixesbptato2024-07-131-5/+5
| | | | | | | | It seems registerHandle/unregister doesn't accept cint as handles. Not sure why it even works on 64-bit targets... (maybe some converter weirdness?) Seems best to explicitly cast it away.
* loader: fix fd leaksbptato2024-06-291-0/+2
|
* img, loader: add image resizing, misc fixesbptato2024-06-283-62/+66
| | | | | | | | | | | | | | | * resize images with stb_image_resize * use tee for output handle redirection (redirectToFile blocks) * cache original image files * accept lseek in sandbox * misc stbi fixes For now, I just pulled in stb_image_resize v1. v2 is an extra 150K in size, not sure if it's worth the cost. (Either way, we can always switch later if needed, since the API is almost the same.) Next step: move sixel/kitty encoders to CGI, and cache their output in memory instead of the intermediate RGBA representation.
* loader: fix failing assertionbptato2024-06-221-2/+4
| | | | | There is no guarantee that iclose is called exactly at rsBeforeStatus or rsBeforeHeaders.
* misc cleanupsbptato2024-06-221-1/+1
|
* client, pager: fix cached item refcounting bugsbptato2024-06-211-16/+36
|
* img, term: try to detect unknown images, improve kitty encoderbptato2024-06-211-2/+3
| | | | | | * preserve alpha in kitty + simplify encoder * pass unknown image types to stbi (as image/x-unknown) and let it detect the type
* img: use stb_image, drop zlib as dependencybptato2024-06-201-1/+1
| | | | | | | Now we have decoders for gif, jpeg, bmp. Also, the in-house PNG decoder has been replaced in favor of the stbi implementation; this means we no longer depend on zlib, since stbi comes with a built in inflate implementation.
* loader: better error handlingbptato2024-06-203-20/+30
| | | | we no longer crash on broken codecs. yay
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-205-169/+258
| | | | | | | | | | | | | | | * multi-processed and sandboxed PNG decoding & encoding (through local CGI) * improved request body passing (including support for output id as response body) * simplified & faster blob()/text() - now every request starts suspended, and OngoingData.buf has been replaced with loader's buffering capability * image caching: we no longer pull bitmaps from the container after every single getLines call Next steps: replace our bespoke PNG decoder with something more usable, add other decoders, and make them stream.
* Update Chame, Chagashibptato2024-06-131-5/+1
|
* pager, buffer: improve forms, protocol configbptato2024-06-081-16/+0
| | | | | | * refactor form submission * add options to specify form handling per protocol * block cross-protocol POST requests
* Move JS wrapper into Monouchabptato2024-06-034-18/+21
| | | | Operation "modularize Chawan somewhat" part 3
* js: change jsstfunc syntaxbptato2024-06-031-1/+1
| | | | | | Interface:function -> Interface.function for consistency with regular JS syntax
* html: improve Request, derive Client from Windowbptato2024-05-204-148/+149
| | | | | | | * make Client an instance of Window (for less special casing) * misc work on Request & fetch * improve origin comparison (opaque origins of same URLs are now considered the same)
* config: separate tmp dir for sockets, usersbptato2024-05-161-1/+2
| | | | | | | * add $LOGNAME to the tmp directory name, so that tmpdirs of separate users don't conflict * use separate directory for sockets, so that we do not have to give buffers access to all cached pages