GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — libprocessing ffi error handling by tychedelia · Pull Request #1293 · processing/processing4

Conversation

@tychedelia

@tychedelia tychedelia commented Oct 16, 2025

Copy link
Copy Markdown
Member

Sets up basic bevy App initialization and cross-FFI error handling.

Our strategy here is the following: Java should do any validation necessary before calling into the FFI layer. Errors are assumed to be unrecoverable and evidence of us doing something wrong. So we don't return error codes or anything but just check the error status as a string so we can at least throw a helpful exception for bug reports.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tychedelia
FFI error setup
b3d9d84
@tychedelia
tychedelia requested a review from catilac October 16, 2025 20:59
@tychedelia
Clear before init.
f490e94
catilac
catilac reviewed Oct 16, 2025
View reviewed changes
Comment thread libProcessing/Cargo.toml Resolved

Uh oh!

There was an error while loading. Please reload this page.

catilac
catilac reviewed Oct 16, 2025
View reviewed changes
Comment thread libProcessing/renderer/Cargo.toml
tracing = "0.1"
tracing-subscriber = "0.3"
bevy = { version = "0.16", no-default-features = true, features = [
"bevy_render"

@catilac catilac Oct 16, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for wayland windowing we need to add "wayland" to the features array

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@catilac catilac Oct 16, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's helpful, i can do it separately so i can actually test

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tychedelia tychedelia Oct 16, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll def need more fleshing out here, i think there's a bunch of other stuff we'll want too. we're just generally going to be doing the "annoying" bevy integration version where we fine grain select what we want. this is to keep the final dylib small for packaging. see also the recently merged bevyengine/bevy#21472 which could be helpful for us.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

catilac reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@catilac catilac Oct 17, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks cool. maybe useful for per-target customization

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
catilac
catilac approved these changes Oct 17, 2025
View reviewed changes

@catilac catilac left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I like the error approach too. And if we ever for whatever reason needed to share more details then we can just serialize more information.

I'm approving, but also curious about what things will look like, say, if they write an erroneous compute shader.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread libProcessing/renderer/Cargo.toml
tracing = "0.1"
tracing-subscriber = "0.3"
bevy = { version = "0.16", no-default-features = true, features = [
"bevy_render"

@catilac catilac Oct 17, 2025

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks cool. maybe useful for per-target customization

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Stefterv
Stefterv reviewed Oct 17, 2025
View reviewed changes
Comment thread core/src/processing/webgpu/PWebGPU.java
*/
public static long add(long left, long right) {
return processing_h.processing_add(left, right);
private static void checkError() {

@Stefterv Stefterv Oct 17, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this means we would need to poll the rust side for any errors?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tychedelia tychedelia Oct 17, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, this is a tedious consequence of ffi code. there are a few different c-style error patterns you can use, but they're all pretty manual. rust exceptions (panics) can't cross the ffi boundary (doing so is undefined behavior).

realistically, we'll probably only end up having like 20ish ffi functions. if we had hundreds, i'd suggest writing an annotation processor or some other kind of reflection magic in java to automate this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Stefterv Stefterv Oct 17, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay and there is no way from Rust to push an event into Java?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tychedelia

tychedelia commented Oct 17, 2025

Copy link
Copy Markdown
Member Author

I'm approving, but also curious about what things will look like, say, if they write an erroneous compute shader.

i think we'll def run into situations like this. what i'd propose is that we write a validate_shader ffi function that can eagerly check and return structured output. but also, there's nothing preventing us from returning a custom ffi error type for a given operation where it would be helpful, for example:

struct ValidationResult {
    error_code: u8,
    data: *const c_void,
}

in rust applications, you typically will bubble up Result using ? to a top level handler that will either log or panic. and so the pattern in this pr basically just ensure that we can reliably return results from our internal library code.

on the java side, we're using unchecked exceptions. right now it's just a general "something went wrong" exception class, but we could totally add an error code in addition to message and sub-type more on the java side if we do want to throw something like ValidationException.

catilac reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@catilac
catilac merged commit 33b8b52 into processing:the-wgpu-moment Oct 17, 2025
catilac added a commit that referenced this pull request Jul 8, 2026
@tychedelia @catilac @Stefterv
Merge WebGPU backend (#1514)
25bca44
* *:ꔫ:*Renderer Project*:ꔫ:*

* Create workspaces for ffi and the renderer (#1275)

* Inital scaffold for libprocessing ffi.

* Remove EAP.

* Update docs.

* Factor out gradle utils. Add flag for disabling webgpu and enforcing android source level compat.

* Remove processing.h

* Set java version for all projects.

* libprocessing ffi error handling (#1293)

* FFI error setup

* Clear before init.

* Basic app lifecycle / surface creation.

* Throw when not on macos.

* Implement `background` method (#1308)

* Implement background.

* Install wayland deps.

* Support for windows surfaces. (#1310)

* Implement basic rendering flow (#1322)

* Implement basic rendering flow

* Fix naming.

* Actually fix rename.

* libprocessing submodule

* --recursive when cloning repo

* Enable submodule checkout in Gradle workflow

Added support for submodules in the checkout step.

* Enable submodules in checkout steps

Added submodule support to the checkout steps.

* Wayland support with new WebGPU renderer

* Gradle fixes from libprocessing refactor. (#1346)

* Updates from libprocessing. (#1392)

* Updates from libprocessing.

* Fixes for compat with main 17.

* Fixup docs.

* Upgrade to jdk-25.

* Upgrade to jdk-25.

* Materials, lights, input event forwarding, ellipse fix.

* Get the gradle sketch runner working locally.

* Conditionally execute webgpu tests

* ProcessingLibraryPlugin JVM Toggle update

* 4.5.5 in gradle.properties

* ProcessingPlugin fixes

---------

Co-authored-by: Moon D. <[email protected]>
Co-authored-by: Moon <[email protected]>
Co-authored-by: Stef Tervelde <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@catilac catilac catilac approved these changes
+1 more reviewer
@Stefterv Stefterv Stefterv left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@tychedelia @catilac @Stefterv
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.