Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean ops crash in WASM only #1121

Open
dabreegster opened this issue Oct 9, 2023 · 4 comments
Open

Boolean ops crash in WASM only #1121

dabreegster opened this issue Oct 9, 2023 · 4 comments
Labels

Comments

@dabreegster
Copy link
Collaborator

We hit georust/geo#976 sometimes in the LTN tool with some boundaries. geom in this codebase has std::panic::catch_unwind around it, but this doesn't work in WASM! https://stackoverflow.com/questions/59426545/rust-paniccatch-unwind-no-use-in-webassembly

Possible workarounds listed there

@RobWalt
Copy link

RobWalt commented Oct 31, 2023

Please refer to this PR georust/geo#1089. There's a new implementation on it's way which returns Results instead of panicing. It also didn't really hit any of the Err cases for all the existing tests yet.

@dabreegster
Copy link
Collaborator Author

Super exciting to see the new implementation! I am completely swamped with work the next few weeks, but it should be pretty quick for me to then swap over the implementation used here and either confirm many bugs go away or provide new test cases.

@RobWalt
Copy link

RobWalt commented Nov 1, 2023

Just out of curiosity: What's your use case in this repo here?

@dabreegster
Copy link
Collaborator Author

The main use is in drawing low traffic neighbourhood "cells". If you click on an area in https://play.abstreet.org/0.3.48/ltn.html?system/gb/bristol/maps/east.bin, it's split into colored areas showing what's reachable by car without leaving the area. https://dabreegster.github.io/talks/aiuk_ltn/slides.html#/approximating-with-grids-1 describes how it's calculated -- approximate the area with a grid, floodfill different colors out. The end result needs to be clipped to the polygon of the overall area. That works most of the time, but I've hit a few cases that crash.

I think I have some other ideas for using boolean ops in related projects. The way this tool calculates "an area bounded by main roads" is quite brittle and complex, gluing together road edge-lines calculated (very imperfectly) from OpenStreetMap. I'd like to try simpler approaches like

  1. Find all "severances" like main roads, railway, rivers
  2. Possibly buffer linestrings into thicker polygons
  3. Split the overall area by these lines
    Some of these might need other primitive geometric operations, but I think boolops could help. So, thanks a ton for working on a more robust implementation! I imagine it has really wide use.

@dabreegster dabreegster added the ltn label Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants