Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/consumers/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Run from the repository root after packaging the Java jars and unpacking natives.
set -euo pipefail
version=${1:?Usage: check.sh PROJECT_VERSION}
output="$PWD/target/consumers"
mkdir -p "$output/classpath" "$output/modulepath"

jars=("$PWD/webrtc/target/webrtc-java-$version.jar"
"$PWD/webrtc-media/target/webrtc-java-media-$version.jar"
"$PWD/webrtc-javafx/target/webrtc-java-javafx-$version.jar")
# These checks run on Linux. Use the real JavaFX modules, not its empty
# platform-neutral jars (which would introduce duplicate automatic modules).
for component in base graphics; do
matches=(webrtc-javafx/target/dependency/javafx-"$component"-*-linux.jar)
if [[ ${#matches[@]} != 1 || ! -f ${matches[0]} ]]; then
echo "Expected one Linux JavaFX $component jar" >&2
exit 1
fi
jars+=("$PWD/${matches[0]}")
done
for jar in "${jars[@]}"; do test -f "$jar"; done
libraries=$(IFS=:; echo "${jars[*]}")
natives="$PWD/webrtc-media/target/natives"
source=.github/consumers/src/consumer/Smoke.java

javac --release 11 -cp "$libraries" -d "$output/classpath" "$source"
java -cp "$output/classpath:$libraries:$natives" consumer.Smoke

javac --release 11 --module-path "$libraries" -d "$output/modulepath" \
.github/consumers/modulepath/module-info.java "$source"
java --module-path "$output/modulepath:$libraries" -cp "$natives" \
--module webrtc.consumer/consumer.Smoke
5 changes: 5 additions & 0 deletions .github/consumers/modulepath/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module webrtc.consumer {
requires webrtc.java;
requires webrtc.java.media;
requires webrtc.java.javafx;
}
40 changes: 40 additions & 0 deletions .github/consumers/src/consumer/Smoke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package consumer;

import dev.onvoid.webrtc.PeerConnectionFactory;
import dev.onvoid.webrtc.client.WebRtc;
import dev.onvoid.webrtc.client.javafx.VideoView;
import dev.onvoid.webrtc.media.audio.AudioDeviceModule;
import dev.onvoid.webrtc.media.audio.AudioLayer;
import dev.onvoid.webrtc.media.player.FFmpeg;
import dev.onvoid.webrtc.media.player.MediaPlayer;
import dev.onvoid.webrtc.media.recorder.MediaRecorderState;

/** A real consumer: compiled and run without test dependencies or add-exports. */
public final class Smoke {
public static void main(String[] args) {
// Resolve all three public modules, including JavaFX, without opening a UI.
System.out.println(MediaPlayer.class.getName());
System.out.println(VideoView.class.getName());
System.out.println(MediaRecorderState.values().length);
WebRtc.builder();

// Exercise JNI on the minimum supported runtime without audio hardware.
AudioDeviceModule audio = new AudioDeviceModule(AudioLayer.kDummyAudio);
try {
PeerConnectionFactory factory = new PeerConnectionFactory(audio);
try {
String version = FFmpeg.version();
if (version == null || version.isEmpty()) {
throw new AssertionError("FFmpeg did not report its version");
}
System.out.println("FFmpeg " + version);
}
finally {
factory.dispose();
}
}
finally {
audio.dispose();
}
}
}
39 changes: 39 additions & 0 deletions .github/workflows/platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,42 @@ jobs:
java-distribution: ${{ matrix.platform.java-distribution }}
java-architecture: ${{ matrix.platform.java-architecture }}
version: ${{ inputs.version }}

# JUnit 6 needs Java 17. Compile and run independent consumers on Java 11
# instead, using the same Linux natives the suite has just tested.
- name: Set up minimum runtime JDK 11
if: matrix.platform.name == 'linux_x86-64'
uses: actions/setup-java@v6
with:
java-version: '11'
distribution: temurin

- name: Check API compatibility and package Java artifacts
if: matrix.platform.name == 'linux_x86-64'
run: |
rm -rf webrtc/target/classes webrtc-media/target/classes webrtc-javafx/target/classes
mvn -B -pl webrtc,webrtc-media,webrtc-javafx -am verify \
-Papi-compatibility -DskipNativeBuild -Dmaven.test.skip=true \
-Dmaven.antrun.skip=true

- name: Resolve JavaFX for consumer compilation
if: matrix.platform.name == 'linux_x86-64'
run: >-
mvn -B -pl webrtc-javafx -am
org.apache.maven.plugins:maven-dependency-plugin:3.7.0:copy-dependencies
-DincludeGroupIds=org.openjfx -DincludeScope=compile

- name: Compile and run classpath and modulepath consumers on Java 11
if: matrix.platform.name == 'linux_x86-64'
shell: bash
run: |
VERSION=$(sed -n 's|.*<version>\([^<]*\)</version>.*|\1|p' pom.xml | head -n 1)
bash .github/consumers/check.sh "$VERSION"

- name: Upload API compatibility reports
if: failure() && matrix.platform.name == 'linux_x86-64'
uses: actions/upload-artifact@v7
with:
name: api-compatibility-reports
path: '**/target/japicmp/'
if-no-files-found: ignore
30 changes: 30 additions & 0 deletions docs/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,36 @@ mvn install

On the first run, the WebRTC source tree is loaded into the `/<user home>/webrtc` directory, and FFmpeg and dav1d are built into `/<user home>/ffmpeg`. This takes a long time. Later builds reuse both as long as their configuration is unchanged. To build the native libraries without running the tests, use `mvn package -DskipTests`, as CI does.

## Java artifact reproducibility and compatibility

Java archives use the version-controlled `project.build.outputTimestamp` in the
parent pom instead of the current build time. Keep the JDK and Maven versions
fixed when comparing hashes. A source archive needs no Git metadata to reproduce
this timestamp; it can also be overridden with
`-Dproject.build.outputTimestamp=<ISO-8601 timestamp>`. Native binaries require
additional measures before their builds can be considered reproducible.

After building or installing the host native artifact, compare the public core
and media APIs against the pinned previous release:

```shell
mvn -pl webrtc,webrtc-media -am verify -Papi-compatibility -DskipNativeBuild
```

The baseline is `api.compatibility.version` in the parent pom. Advance it after a
release. The two member-level exceptions record breaks already made since
0.20.0 (#395 and #421); remove them when advancing that baseline. Internal
packages are excluded. Reports are written to each module's `target/japicmp/`.
JavaFX is new since that release and has no published baseline yet; enable the
same profile there once its first release is available.

CI additionally packages all three Java libraries on JDK 11 with tests skipped
(JUnit 6 itself requires 17), then compiles and runs the consumers under
`.github/consumers/` separately on the classpath and modulepath. They resolve the
public client, media and JavaFX APIs and exercise native factory creation and
FFmpeg loading without hardware or a display. They use the Linux native jars
from the platform build, without `--add-exports` or `--add-opens`.

## Build Parameters

| Parameter | Description | Default Value |
Expand Down
47 changes: 44 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
</scm>

<properties>
<timestamp>${maven.build.timestamp}</timestamp>
<!-- Version-controlled timestamp; Maven Release updates it for releases. -->
<project.build.outputTimestamp>2026-10-31T23:43:19Z</project.build.outputTimestamp>
<api.compatibility.version>0.20.0</api.compatibility.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
</properties>

<modules>
Expand All @@ -61,6 +62,47 @@
<pluginManagement>
<!-- Set versions of common plugins for reproducibility, ordered alphabetically. -->
<plugins>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
<version>0.26.3</version>
<configuration>
<oldVersion>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${api.compatibility.version}</version>
</dependency>
</oldVersion>
<newVersion>
<file>
<path>${project.build.directory}/${project.build.finalName}.jar</path>
</file>
</newVersion>
<parameter>
<accessModifier>protected</accessModifier>
<onlyModified>true</onlyModified>
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
<excludes>
<!-- Changes already made after 0.20.0: #395 removed the
obsolete logging switch; #421 hid an unsafe JNI entry point.
Remove these exceptions when advancing the baseline. -->
<exclude>dev.onvoid.webrtc.logging.Logging#logThreads(boolean)</exclude>
<exclude>dev.onvoid.webrtc.media.audio.AudioConverter#convertInternal(byte[],int,byte[],int)</exclude>
<exclude>dev.onvoid.webrtc.internal</exclude>
<exclude>dev.onvoid.webrtc.client.internal</exclude>
</excludes>
</parameter>
</configuration>
<executions>
<execution>
<id>api-compatibility</id>
<phase>verify</phase>
<goals><goal>cmp</goal></goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
Expand Down Expand Up @@ -145,7 +187,6 @@
<compress>true</compress>
<manifestEntries>
<Version>${project.version}</Version>
<Build-Date>${maven.build.timestamp}</Build-Date>
</manifestEntries>
</archive>
<skipIfEmpty>true</skipIfEmpty>
Expand Down
12 changes: 12 additions & 0 deletions webrtc-media/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,18 @@
</dependencies>

<profiles>

<profile>
<id>api-compatibility</id>
<build>
<plugins>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<!-- Runs the tests against natives built elsewhere, as the
test-natives lane does after unpacking them into target/natives,
which is where Surefire is already told to look. -->
Expand Down
12 changes: 12 additions & 0 deletions webrtc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
</build>

<profiles>

<profile>
<id>api-compatibility</id>
<build>
<plugins>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<!--
Opt-in JNI reference-discipline check: runs the same tests under
-Xcheck:jni, which validates every JNI call's local/global refs and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static synchronized Path processDirectory(Path tempRoot) throws IOException {
* @throws Exception if the library is not in the JAR or could not be
* loaded.
*/
private static void loadFromDirectory(Path directory, String fileName)
static void loadFromDirectory(Path directory, String fileName)
throws Exception {
Path libPath = directory.resolve(fileName);

Expand All @@ -313,7 +313,12 @@ private static void loadFromDirectory(Path directory, String fileName)
System.load(libPath.toAbsolutePath().toString());
}
catch (Throwable e) {
Files.deleteIfExists(libPath);
try {
Files.deleteIfExists(libPath);
}
catch (IOException | RuntimeException cleanupError) {
e.addSuppressed(cleanupError);
}

throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

package dev.onvoid.webrtc.internal;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

Expand Down Expand Up @@ -52,6 +55,32 @@ class NativeLoaderTests extends TestBase {
Path root;


@Test
void preservesLoadFailure() throws Exception {
Path library = Files.write(root.resolve("invalid-library"), new byte[] { 0 });

UnsatisfiedLinkError error = assertThrows(UnsatisfiedLinkError.class,
() -> NativeLoader.loadFromDirectory(root, library.getFileName().toString()));

assertEquals(0, error.getSuppressed().length);
assertFalse(Files.exists(library));
}

@Test
void suppressesCleanupFailure() throws Exception {
// Loading a directory fails; its child makes deletion fail on every OS,
// without depending on permissions or timing.
Path library = Files.createDirectory(root.resolve("invalid-library"));
Files.createFile(library.resolve("child"));

UnsatisfiedLinkError error = assertThrows(UnsatisfiedLinkError.class,
() -> NativeLoader.loadFromDirectory(root, library.getFileName().toString()));

assertEquals(1, error.getSuppressed().length);
assertInstanceOf(IOException.class, error.getSuppressed()[0]);
assertTrue(error.getMessage().contains(library.toAbsolutePath().toString()));
}

@Test
void sweepsEndedProcess() throws Exception {
Path directory = extraction("ended", true);
Expand Down
Loading