Skip to content

[Help wanted] PostGIS#807

Draft
tdrz wants to merge 101 commits intomainfrom
tdrz/frontend-try-postgis2
Draft

[Help wanted] PostGIS#807
tdrz wants to merge 101 commits intomainfrom
tdrz/frontend-try-postgis2

Conversation

@tdrz
Copy link
Collaborator

@tdrz tdrz commented Oct 3, 2025

[HELP WANTED]

Please follow the comments in this thread for updates.


We are looking for help making PostGIS a reality for PGlite.

The bulk of the work has been done, the extension is built as part of the entire build process and there are even a few PostGIS test that pass! But some don't, see all of them in packages/pglite/tests/postgis.test.ts.

There are multiple issues:

  1. Identify the missing exported functions that PostGIS is expecting from PGlite (they need to be added to postgres-pglite/pglite-wasm/included.pglite.imports). We think we have achieved this - more tests needed.
  2. For the moment, we don't want to use threads in PGlite, so all dependencies and PostGIS itself need to explicitly be built without threads support. Some are already, see postgres-pglite/pglite-wasm/builder/Dockerfile but some are not because pthread required functions still sneak in.
  3. Add more tests such that we are sure the PostGIS works as expected. Ideally we would run PostGIS tests against a PGlite instance (possibly using pglite-socket).
  4. Manual test - if you have an app that uses Postgresql + PostGIS, please try it with PGlite + PostGIS (you can manually download the package that contains it from a CI run related to this PR).

Other:
a. Although libgdal is present in the docker builder image, it is not currently used by the final extension. Something to look into.
b. I've build all deps as static libs and now I am doubting that this is the right course of actions (mainly because of difficulties of also linking libgdal to the final extension).

Update 2026.01.08:
It is possible to run PostGIS' own unit tests against PGlite (through pglite-socket), but those fail atm, so we're not ready to merge this.

@tdrz
Copy link
Collaborator Author

tdrz commented Jan 7, 2026

Go to PostGIS repository, comment lines in a file regress/run_test.pl with calls to functions prepare_spatial and prepare_spatial_extensions, run make check and provide password for every test.

@StachowiakDawid Why do those calls need to be commented out?

@StachowiakDawid
Copy link

Go to PostGIS repository, comment lines in a file regress/run_test.pl with calls to functions prepare_spatial and prepare_spatial_extensions, run make check and provide password for every test.

@StachowiakDawid Why do those calls need to be commented out?

Because I use 2 PostGIS builds for tests. One is in WASM for PGLite, so I can start PGLite server and bind it to the default Unix socket, the other one is normal build for Linux, which I use to run tests. make check is programmed to run tests before installing PostGIS extension, method prepare_spatial loads all PostGIS functions temporarily from postgis-3.so file, which PGLite obviously doesn't have access to (and doesn't need it, because we compiled it with PostGIS support earlier).

If you manage to run make check in WASM (I don't have any experience with compiling WASM apps, so I can't help), there is no need for such workarounds, but if it is a major blocker, I would go for a second Docker image (or extend current Docker image with Node) just for testing PostGIS.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

@tdrz
Copy link
Collaborator Author

tdrz commented Jan 8, 2026

If you manage to run make check in WASM (I don't have any experience with compiling WASM apps, so I can't help), there is no need for such workarounds, but if it is a major blocker, I would go for a second Docker image (or extend current Docker image with Node) just for testing PostGIS.

We need to run the postgis tests against the WASM build.

Here's what I got so far: open 2 terminals.

  • Terminal 1:
$ ./packages/pglite-socket/dist/scripts/server.js -u /tmp/.s.PGSQL.5432 -e postgis
  • Terminal 2:
$ cd ./postgres-pglite/pglite/postgis/regress/
$ PGPASSWORD=any_password PGPORT=5432 PGHOST=/tmp PGUSER=postgres perl ./postgres-pglite/pglite/postgis/regress/run_test.pl --extension core/regress core/wkt core/measures core/geography core/operators

Output:

  • Terminal 1:
Initializing PGLite with database: memory://
Debug level: 0
Imported extension: postgis
PGlite database initialized
PGLiteSocketServer listening on {"path":"/tmp/.s.PGSQL.5432"}
Client connected from unknown:0
Client connected from unknown:0
[...]
Client connected from unknown:0
Socket server error: RuntimeError: unreachable
    at wasm://wasm/021b5c0a:wasm-function[3714]:0x282e7b
    at invoke_v (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite/dist/index.js:3:223501)
    at wasm://wasm/021b5c0a:wasm-function[185]:0x608a7
    at G.execProtocolRawSync (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite/dist/index.js:3:234719)
    at G.execProtocolRaw (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite/dist/index.js:3:234891)
    at a.handleData (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite-socket/dist/chunk-F6KLIXM7.js:1:2032)
    at Socket.<anonymous> (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite-socket/dist/chunk-F6KLIXM7.js:1:954)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

RuntimeError: unreachable
    at wasm://wasm/021b5c0a:wasm-function[3714]:0x282e7b
    at invoke_v (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite/dist/index.js:3:223501)
    at wasm://wasm/021b5c0a:wasm-function[185]:0x608a7
    at G.execProtocolRawSync (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite/dist/index.js:3:234719)
    at G.execProtocolRaw (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite/dist/index.js:3:234891)
    at a.handleData (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite-socket/dist/chunk-F6KLIXM7.js:1:2032)
    at Socket.<anonymous> (file:///home/tdr/src/tudor/electric-sql/frontend-try-postgis2/packages/pglite-socket/dist/chunk-F6KLIXM7.js:1:954)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)

Node.js v22.21.1
  • Terminal 2:
Creating database 'postgis_reg'.
Preparing db 'postgis_reg' using: CREATE EXTENSION postgis SCHEMA public
DEBUG:  Function postgis_gdal_version() not found.  Is raster support enabled and rtpostgis.sql installed?
DEBUG:  Function postgis_sfcgal_scripts_installed() not found. Is sfcgal support enabled and sfcgal.sql installed?
DEBUG:  Function postgis_topology_scripts_installed() not found. Is topology support enabled and topology.sql installed?
DEBUG:  Function postgis_raster_scripts_installed() not found. Is raster support enabled and rtpostgis.sql installed?
DEBUG:  Function postgis_raster_lib_version() not found. Is raster support enabled and rtpostgis.sql installed?
Executor slow factor: 4.4 (44.000 ms to fetch full version)
PostgreSQL 17.5 on aarch64-unknown-linux-gnu, compiled by emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74 (1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5), 32-bit
  Postgis 3.6.1 - (0) - 2026-01-08 09:01:24
  scripts 3.6.1 0
  GEOS: 3.14.0-CAPI-1.20.4
  PROJ: 9.7.0 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/home/web_user/.local/share/proj DATABASE_PATH=/install/libs/share/proj/proj.db

Running tests

 regress/core/regress .. failed (psql exited with an error: /tmp/pgis_reg/test_1_out)
Died at run_test.pl line 979.

Then:

$ cat  /tmp/pgis_reg/test_1_out
1|POINT(1 2)
2|POINT(1 2 3)
3|LINESTRING(0 0,1 1,2 2,3 3,4 4)
4|LINESTRING(0 0 0,1 1 1,2 2 2,3 3 3,4 4 4)
5|LINESTRING(1 2 3,4 5 6,7 8 9,10 11 12,13 14 15)
6|POLYGON((0 0,10 0,10 10,0 10,0 0))
7|POLYGON((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1))
8|POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))
9|POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5),(1 1,2 1,2 2,1 2,1 1))
10|POLYGON((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1))
11|POLYGON((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1),(1 1 1,2 1 1,2 2 1,1 2 1,1 1 1))
12|GEOMETRYCOLLECTION(POINT(1 2))
13|GEOMETRYCOLLECTION(POINT(1 2 3))
14|GEOMETRYCOLLECTION(LINESTRING(0 0,1 1,2 2,3 3,4 4))
15|GEOMETRYCOLLECTION(LINESTRING(1 2 3,4 5 6,7 8 9,10 11 12,13 14 15))
16|GEOMETRYCOLLECTION(POLYGON((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1)))
17|GEOMETRYCOLLECTION(POINT(1 2 0),POINT(1 2 3))
18|GEOMETRYCOLLECTION(LINESTRING(0 0 0,1 1 0,2 2 0,3 3 0,4 4 0),POINT(1 2 3))
19|GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(0 0,1 1,2 2,3 3,4 4))
20|GEOMETRYCOLLECTION(POINT(1 2 0),POINT(1 2 3),LINESTRING(1 2 3,4 5 6,7 8 9,10 11 12,13 14 15))
21|GEOMETRYCOLLECTION(POINT(1 2 0),POINT(1 2 3),LINESTRING(1 2 3,4 5 6,7 8 9,10 11 12,13 14 15),POLYGON((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)))
22|GEOMETRYCOLLECTION(POINT(1 2 0),POINT(1 2 3),POLYGON((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1),(1 1 1,2 1 1,2 2 1,1 2 1,1 1 1)))
23|MULTIPOINT(1 2)
24|MULTIPOINT(1 2 3)
25|MULTIPOINT(1 2,3 4,5 6)
26|MULTIPOINT(1 2 3,5 6 7,8 9 10,11 12 13)
27|MULTIPOINT(1 2 0,1 2 3,4 5 0,6 7 8)
28|MULTIPOINT(1 2 3,4 5 0)
29|MULTILINESTRING((0 0,1 1,2 2,3 3,4 4))
30|MULTILINESTRING((0 0,1 1,2 2,3 3,4 4),(0 0,1 1,2 2,3 3,4 4))
31|MULTILINESTRING((0 0 0,1 1 0,2 2 0,3 3 0,4 4 0),(0 0 0,1 1 0,2 2 0,3 3 0,4 4 0),(1 2 3,4 5 6,7 8 9,10 11 12,13 14 15))
32|MULTILINESTRING((1 2 3,4 5 6,7 8 9,10 11 12,13 14 15),(0 0 0,1 1 0,2 2 0,3 3 0,4 4 0),(0 0 0,1 1 0,2 2 0,3 3 0,4 4 0))
33|MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))
34|MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5)))
35|MULTIPOLYGON(((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)),((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0),(5 5 0,7 5 0,7 7 0,5 7 0,5 5 0)),((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1),(1 1 1,2 1 1,2 2 1,1 2 1,1 1 1)))
36|GEOMETRYCOLLECTION(MULTIPOINT(1 2))
37|GEOMETRYCOLLECTION(MULTIPOINT(1 2 3))
38|GEOMETRYCOLLECTION(MULTIPOINT(1 2 3,5 6 7,8 9 10,11 12 13))
39|GEOMETRYCOLLECTION(MULTILINESTRING((0 0,1 1,2 2,3 3,4 4)))
40|GEOMETRYCOLLECTION(MULTILINESTRING((1 2 3,4 5 6,7 8 9,10 11 12,13 14 15),(0 0 0,1 1 0,2 2 0,3 3 0,4 4 0),(0 0 0,1 1 0,2 2 0,3 3 0,4 4 0)))
41|GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)),((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0),(5 5 0,7 5 0,7 7 0,5 7 0,5 5 0)),((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1),(1 1 1,2 1 1,2 2 1,1 2 1,1 1 1))))
42|GEOMETRYCOLLECTION(POINT(1 2 0),MULTIPOINT(1 2 3))
43|GEOMETRYCOLLECTION(MULTIPOINT(1 2 0,3 4 0,5 6 0),POINT(1 2 3))
44|GEOMETRYCOLLECTION(POINT(1 2 3),MULTILINESTRING((0 0 0,1 1 0,2 2 0,3 3 0,4 4 0)))
45|GEOMETRYCOLLECTION(MULTILINESTRING((0 0 0,1 1 0,2 2 0,3 3 0,4 4 0)),POINT(1 2 3))
46|GEOMETRYCOLLECTION(POINT(1 2 3),MULTIPOLYGON(((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)),((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0),(5 5 0,7 5 0,7 7 0,5 7 0,5 5 0)),((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1),(1 1 1,2 1 1,2 2 1,1 2 1,1 1 1))))
47|GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)),((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0),(5 5 0,7 5 0,7 7 0,5 7 0,5 5 0)),((0 0 1,10 0 1,10 10 1,0 10 1,0 0 1),(5 5 1,7 5 1,7 7 1,5 7 1,5 5 1),(1 1 1,2 1 1,2 2 1,1 2 1,1 1 1))),MULTILINESTRING((0 0 0,1 1 0,2 2 0,3 3 0,4 4 0),(0 0 0,1 1 0,2 2 0,3 3 0,4 4 0),(1 2 3,4 5 6,7 8 9,10 11 12,13 14 15)),MULTIPOINT(1 2 3,5 6 7,8 9 10,11 12 13))
48|MULTIPOINT(-1 -2 -3,5.4 6.6 7.77,-5.4 -6.6 -7.77,1000000 0.000001 -1000000,-0.0000013 -0.000014 0)
49|GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(1 1)))
psql:regress.sql:68: ERROR:  parse error - invalid geometry at character 14
psql:regress.sql:69: ERROR:  parse error - invalid geometry at character 14
psql:regress.sql:70: ERROR:  parse error - invalid geometry at character 14
psql:regress.sql:71: ERROR:  parse error - invalid geometry at character 14
psql:regress.sql:72: ERROR:  parse error - invalid geometry at character 14
psql:regress.sql:73: ERROR:  parse error - invalid geometry at character 14
psql:regress.sql:74: ERROR:  geometry contains non-closed rings at character 24
psql:regress.sql:75: ERROR:  geometry contains non-closed rings at character 24
psql:regress.sql:76: ERROR:  parse error - invalid geometry at character 24
psql:regress.sql:80: ERROR:  geometry has too many points at character 23
psql:regress.sql:81: ERROR:  parse error - invalid geometry at character 23
psql:regress.sql:82: ERROR:  geometry requires more points at character 23
62|POINT(inf 0)
63|POINT(-inf 0)
psql:regress.sql:87: ERROR:  parse error - invalid geometry at character 23
65|t
65a|t
66|t
66a|f
67|t
67a|t
68|t
68a|t
69|t
69a|f
70|t
70a|f
71|t
71a|f
72|t
72a|f
73|t
73a|f
74|f
74a|f
75|t
75a|f
76|f
76a|f
106|BOX3D(0 0 0,7 7 0)
107a|POINT(1 2 3)
107b|LINESTRING(2 3 3,7 3 3)
107c|POLYGON((2 3 5,2 8 5,6 8 5,6 3 5,2 3 5))
107d|POLYGON((1 -1 4,2 -1 4,2 -1 9,1 -1 9,1 -1 4))
107e|POLYGON((-1 3 5,-1 6 5,-1 6 8,-1 3 8,-1 3 5))
107f|POLYHEDRALSURFACE(((1 2 3,1 5 3,4 5 3,4 2 3,1 2 3)),((1 2 6,4 2 6,4 5 6,1 5 6,1 2 6)),((1 2 3,1 2 6,1 5 6,1 5 3,1 2 3)),((4 2 3,4 5 3,4 5 6,4 2 6,4 2 3)),((1 2 3,4 2 3,4 2 6,1 2 6,1 2 3)),((1 5 3,1 5 6,4 5 6,4 5 3,1 5 3)))
108|2
109|4
110|6
111|552
112|3
psql:/home/tdr/src/tudor/electric-sql/frontend-try-postgis2/postgres-pglite/pglite/postgis/regress/core/regress_biginsert.sql:1: server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
psql:/home/tdr/src/tudor/electric-sql/frontend-try-postgis2/postgres-pglite/pglite/postgis/regress/core/regress_biginsert.sql:1: error: connection to server was lost

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

@tdrz
Copy link
Collaborator Author

tdrz commented Jan 8, 2026

There is an issue when running in the browser:

CREATE EXTENSION postgis;
could not load library "/tmp/pglite/lib/postgresql/postgis-3": Could not load dynamic lib: /tmp/pglite/lib/postgresql/postgis-3 RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 8MB. Use WebAssembly.compile, compile on a worker thread, or use the flag `--enable-features=WebAssemblyUnlimitedSyncCompilation`.

Can be tested here: https://695f7a5d24447a9a943defb2--pglite.netlify.app/repl/
(activate 'postgis')

@StachowiakDawid
Copy link

StachowiakDawid commented Jan 8, 2026

I will try to run the tests this way at the weekend. Regarding the error in the browser, I don't see it in Safari or Firefox.

I sent you an invite to the private repo with my app I mentioned earlier, because I don't want to make it public now. It works on desktop (macOS) Firefox, Safari and Chrome, but it doesn't seem to work on Chrome on Android (I haven't checked debugger yet). And I had to abandon json_agg method, because it hanged the browser.

@tdrz
Copy link
Collaborator Author

tdrz commented Jan 9, 2026

I've identified an issue in the pglite-socket. With that fixed, it already looks pretty good.

Regarding the error in the browser, I don't see it in Safari or Firefox.

Chrome has a 8MB limit on compiling wasm on the main thread.

@StachowiakDawid
Copy link

I've identified an issue in the pglite-socket. With that fixed, it already looks pretty good.

    // Setup event handlers
    this.log(`attach: setting up socket event handlers`)
    let bufferArr: Buffer[] = [];
    socket.on('data', async (data) => {
      try {
        bufferArr.push(data);
        if (data.readUInt8(data.length - 1) !== 0) {
          return;
        }
        const result = await this.handleData(Buffer.concat(bufferArr));
        bufferArr = [];
        this.log(`socket on data sent: ${result} bytes`)
      } catch (err) {
        this.log('socket on data error: ', err)
      }
    })

Running tests:

Creating database 'postgis_reg'.
Preparing db 'postgis_reg' using: CREATE EXTENSION postgis SCHEMA public
DEBUG:  Function postgis_gdal_version() not found.  Is raster support enabled and rtpostgis.sql installed?
DEBUG:  Function postgis_sfcgal_scripts_installed() not found. Is sfcgal support enabled and sfcgal.sql installed?
DEBUG:  Function postgis_topology_scripts_installed() not found. Is topology support enabled and topology.sql installed?
DEBUG:  Function postgis_raster_scripts_installed() not found. Is raster support enabled and rtpostgis.sql installed?
DEBUG:  Function postgis_raster_lib_version() not found. Is raster support enabled and rtpostgis.sql installed?
Executor slow factor: 5.7 (57.000 ms to fetch full version)
PostgreSQL 17.5 on aarch64-unknown-linux-gnu, compiled by emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74 (1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5), 32-bit
  Postgis 3.6.1 - (0) - 2026-01-10 12:59:10
  scripts 3.6.1 0
  GEOS: 3.14.0-CAPI-1.20.4
  PROJ: 9.7.0 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/home/web_user/.local/share/proj DATABASE_PATH=/install/libs/share/proj/proj.db

Running tests

 regress/core/regress .. failed (diff expected obtained: /tmp/pgis_reg/test_1_diff)
 regress/core/wkt .. ok in 50 ms
 regress/core/measures .. ok in 129 ms
 regress/core/geography .. failed (diff expected obtained: /tmp/pgis_reg/test_4_diff)
 regress/core/operators .. ok in 82 ms
 regress/uninstall .. failed (Object count pre-install (5456) != post-uninstall (5458))

Run tests: 6
Failed: 3
DEBUG:  performing replication slot checkpoint
DEBUG:  snapshot of 1+0 running transaction ids (lsn 0/13E3908 oldest xid 752 latest complete 751 next xid 753)
DEBUG:  attempting to remove WAL segments older than log file 000000000000000000000012
DEBUG:  recycled write-ahead log file "000000010000000000000005"
DEBUG:  recycled write-ahead log file "000000010000000000000006"
DEBUG:  recycled write-ahead log file "000000010000000000000007"
DEBUG:  recycled write-ahead log file "000000010000000000000008"
DEBUG:  recycled write-ahead log file "000000010000000000000009"
DEBUG:  recycled write-ahead log file "00000001000000000000000A"
DEBUG:  recycled write-ahead log file "00000001000000000000000B"
DEBUG:  recycled write-ahead log file "00000001000000000000000C"
DEBUG:  recycled write-ahead log file "00000001000000000000000D"
DEBUG:  recycled write-ahead log file "00000001000000000000000E"
DEBUG:  recycled write-ahead log file "00000001000000000000000F"
DEBUG:  recycled write-ahead log file "000000010000000000000010"
DEBUG:  recycled write-ahead log file "000000010000000000000011"
DEBUG:  recycled write-ahead log file "000000010000000000000012"
DEBUG:  SlruScanDirectory invoking callback on pg_subtrans/0000

@StachowiakDawid
Copy link

I forgot to turn off debug messages, now these tests pass:

Creating database 'postgis_reg'.
Preparing db 'postgis_reg' using: CREATE EXTENSION postgis SCHEMA public
ERROR:  relation "_start" already exists
Executor slow factor: 1 ( ms to fetch full version)
PostgreSQL 17.5 on aarch64-unknown-linux-gnu, compiled by emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.74 (1092ec30a3fb1d46b1782ff1b4db5094d3d06ae5), 32-bit
  Postgis 3.6.1 - (0) - 2026-01-10 15:54:59
  scripts 3.6.1 0
  GEOS: 3.14.0-CAPI-1.20.4
  PROJ: 9.7.0 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/home/web_user/.local/share/proj DATABASE_PATH=/install/libs/share/proj/proj.db

Running tests

 regress/core/regress .. ok in 234 ms
 regress/core/wkt .. ok in 37 ms
 regress/core/measures .. ok in 111 ms
 regress/core/geography .. ok in 99 ms
 regress/core/operators .. ok in 67 ms
 regress/uninstall .. ok (5458)

Run tests: 6
Failed: 0

@tdrz
Copy link
Collaborator Author

tdrz commented Jan 12, 2026

@StachowiakDawid how did you turn off the debug messages?

@tdrz
Copy link
Collaborator Author

tdrz commented Jan 12, 2026

I believe the only standing issue atm is the 8MB file size limit that Chrome has on WebAssembly.Compile.

@StachowiakDawid
Copy link

@tdrz SET client_min_messages TO notice; in psql before tests.

Regarding Chrome limit I see two workarounds: static PostgreSQL build (https://blog.davidv.dev/posts/postgres-extensions/) or changing synchronous dlopen to asynchronous emscripten_dlopen in PostGIS code.

Or third option: convince Chrome devs to update limit, because they chose 8 MB for 2016 phone (https://chromestatus.com/feature/5099433642950656).

@tdrz
Copy link
Collaborator Author

tdrz commented Jan 12, 2026

two workarounds: static PostgreSQL build (https://blog.davidv.dev/posts/postgres-extensions/) or changing synchronous dlopen to asynchronous emscripten_dlopen in PostGIS code.

Or third option: convince Chrome devs to update limit, because they chose 8 MB for 2016 phone (https://chromestatus.com/feature/5099433642950656).

The decision that lead to this issue is that I've built all of postgis' as static libraries and linked as whole archives to the final .so. If we can build some/all of postgis' deps as dynamic libraries, each of those deps should be < 8MB and the WebAssembly.Compile would be happy.

@StachowiakDawid
Copy link

The decision that lead to this issue is that I've built all of postgis' as static libraries and linked as whole archives to the final .so. If we can build some/all of postgis' deps as dynamic libraries, each of those deps should be < 8MB and the WebAssembly.Compile would be happy.

Btw I tried

./binaryen-version_125/bin/wasm-opt -Oz

and it reduced size from 9.1MB to 8.4MB. Still too big and may be noticeably slower.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants