Skip to content

Commit 53c4ac4

Browse files
authored
Reduce delays in webRTC remote display. (#7496)
Update libwebrtc to latest (M149). Remove duplicate redraw on input (WebRTCWindowSystem.cpp) Draw coalescing (BitmapWindowSystem.cpp) Input (mouse event) coalescing (BitmapWindowSystem.cpp) JS requestAnimationFrame coalescing / throttling (webrtcstreamer.js) Async encoder thread (PeerConnectionManager.cpp/.h) Data channel low-latency mode (webrtcstreamer.js) Reduced startup delay (500ms -> 250ms) (WebRTCWindowSystem.cpp) VP9 codec preference over VP8 (webrtcstreamer.js) Fix RGB color range: Switch default 16-235 back to 0-255. Improve ASSIMP export texture handling. Also: Check textures for validity before trying to write them to gltf.
1 parent fe3af4b commit 53c4ac4

41 files changed

Lines changed: 1692 additions & 738 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/macos.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ jobs:
6767
- name: Install dependencies
6868
run: |
6969
brew install ccache glslang spirv-cross
70-
# Fix gfortran not found issue
70+
# Fix gfortran not found issue.
71+
brew install gcc
7172
ln -s $(brew --prefix gcc)/bin/gfortran-* /usr/local/bin/gfortran
7273
7374
ccache -M 2G # See .github/workflows/readme.md for ccache strategy.
@@ -202,7 +203,9 @@ jobs:
202203
install_python_dependencies
203204
204205
# Fix macos-14 arm64 runner image issues, see comments in MacOS job.
205-
ln -s $(which gfortran-13) /usr/local/bin/gfortran
206+
# brew install gcc is required so that `brew --prefix gcc` resolves;
207+
brew install gcc
208+
ln -s $(brew --prefix gcc)/bin/gfortran-* /usr/local/bin/gfortran
206209
207210
brew install ccache glslang spirv-cross
208211
ccache -M 2G # See .github/workflows/readme.md for ccache strategy.

.github/workflows/webrtc.yml

Lines changed: 89 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
workflow_dispatch:
66
inputs:
77
webrtc_commit:
8-
description: 'Specify WebRTC commit to build.'
8+
description: 'WebRTC src commit (full or short).'
99
required: false
10-
default: '60e674842ebae283cc6b2627f4b6f2f8186f3317' # Date: Wed Apr 7 19:12:13 2021 +0200
10+
default: 'e8b4d4c5952a8fb7b35c2a6cba4e8c3de2ea2e1e'
1111
depot_tools_commit:
12-
description: 'Specify Depot Tools commit to to use for the build.'
12+
description: 'depot_tools commit (override pin in webrtc_build.sh).'
1313
required: false
14-
default: 'e1a98941d3ab10549be6d82d0686bb0fb91ec903' # Date: Wed Apr 7 21:35:29 2021 +0000
14+
default: '10eda50a3fd9c34ad8d31ec74e5f4eb5823d60f6'
1515

1616
concurrency:
1717
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -20,29 +20,35 @@ concurrency:
2020
env:
2121
WEBRTC_COMMIT: ${{ github.event.inputs.webrtc_commit }}
2222
DEPOT_TOOLS_COMMIT: ${{ github.event.inputs.depot_tools_commit }}
23+
WEBRTC_WORK_ROOT: ${{ github.workspace }}/..
24+
GCLIENT_JOBS: 8
2325

2426
jobs:
2527

2628
Unix:
2729
permissions:
28-
contents: write # upload
30+
contents: read
2931
runs-on: ${{ matrix.os }}
3032
strategy:
3133
fail-fast: false
3234
matrix:
33-
os: [ubuntu-22.04, macos-13]
35+
include:
36+
- os: ubuntu-22.04
37+
package_suffix: linux_cxx-abi-1
38+
- os: macos-14
39+
package_suffix: macos_arm64
3440

3541
steps:
3642
- name: Checkout source code
3743
uses: actions/checkout@v4
3844

39-
- name: Set up Python version
45+
- name: Set up Python
4046
uses: actions/setup-python@v5
4147
with:
42-
python-version: 3.10
48+
python-version: '3.10'
4349

44-
- name: Install dependencies
45-
if: ${{ matrix.os == 'ubuntu-22.04' }}
50+
- name: Install dependencies (Ubuntu)
51+
if: matrix.os == 'ubuntu-22.04'
4652
run: |
4753
source 3rdparty/webrtc/webrtc_build.sh
4854
install_dependencies_ubuntu
@@ -60,116 +66,117 @@ jobs:
6066
- name: Upload WebRTC
6167
uses: actions/upload-artifact@v4
6268
with:
63-
name: webrtc_release_${{ matrix.os }}
69+
name: webrtc_${{ matrix.package_suffix }}
6470
path: |
65-
webrtc_*.tar.gz
66-
checksum_*.txt
71+
webrtc_*.tar.gz
72+
checksum_webrtc_*.tar.gz
6773
if-no-files-found: error
6874

6975
Windows:
7076
permissions:
71-
contents: write # upload
72-
# https://chromium.googlesource.com/chromium/src/+/HEAD/docs/windows_build_instructions.md
77+
contents: read
7378
runs-on: windows-2022
79+
strategy:
80+
fail-fast: false
81+
matrix:
82+
include:
83+
- config: Release
84+
static_runtime: ON
85+
tag: Release_mt
86+
- config: Release
87+
static_runtime: OFF
88+
tag: Release_md
89+
- config: Debug
90+
static_runtime: ON
91+
tag: Debug_mt
92+
- config: Debug
93+
static_runtime: OFF
94+
tag: Debug_md
7495
env:
75-
WORK_DIR: "C:\\WebRTC" # Not enough space in D:
76-
OPEN3D_DIR: "D:\\a\\open3d\\open3d"
77-
DEPOT_TOOLS_UPDATE: 1 # Fix cannot find python3_bin_reldir.txt
78-
DEPOT_TOOLS_WIN_TOOLCHAIN: 0
79-
NPROC: 2
96+
WORK_DIR: 'C:\WebRTC'
97+
OPEN3D_DIR: ${{ github.workspace }}
98+
WEBRTC_WORK_ROOT: 'C:\WebRTC'
99+
DEPOT_TOOLS_UPDATE: 0 # belt-and-suspenders; also set by webrtc_setup_path
100+
DEPOT_TOOLS_WIN_TOOLCHAIN: 0 # use locally installed VS, not the Chromium toolchain
80101

81102
steps:
82103
- name: Checkout source code
83104
uses: actions/checkout@v4
84105

85-
- name: Set up Python version
106+
- name: Set up Python
86107
uses: actions/setup-python@v5
87108
with:
88109
python-version: '3.10'
89110

90-
- name: Disk space
111+
- name: Prepare work directory
112+
shell: pwsh
91113
run: |
92114
Get-PSDrive
93-
mkdir "$env:WORK_DIR"
115+
New-Item -ItemType Directory -Force -Path $env:WORK_DIR
94116
95-
- name: Setup PATH for Visual Studio # Required for Ninja
117+
- name: Setup PATH for Visual Studio
96118
uses: ilammy/msvc-dev-cmd@v1
97119
with:
98120
arch: x64
99121

100122
- name: Download WebRTC sources
101-
shell: pwsh
102-
working-directory: ${{ env.WORK_DIR }}
123+
shell: bash # Git Bash transparently converts Windows-style env paths
103124
run: |
104-
$ErrorActionPreference = 'Stop'
105-
echo "Get depot_tools"
106-
# Checkout to a specific version
107-
# Ref: https://chromium.googlesource.com/chromium/src/+/main/docs/building_old_revisions.md
108-
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
109-
git -C depot_tools checkout $env:DEPOT_TOOLS_COMMIT
110-
$env:Path = (Get-Item depot_tools).FullName + ";" + $env:Path
111-
112-
echo "Get WebRTC"
113-
mkdir webrtc
114-
cd webrtc
115-
fetch webrtc
116-
117-
git -C src checkout $env:WEBRTC_COMMIT
118-
git -C src submodule update --init --recursive
119-
echo "gclient sync"
120-
gclient sync -D --force --reset
121-
cd ..
122-
echo "random.org"
123-
curl "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" -o skipcache
125+
source "$OPEN3D_DIR/3rdparty/webrtc/webrtc_build.sh"
126+
download_webrtc_sources
124127
125128
- name: Patch WebRTC
129+
shell: pwsh
126130
working-directory: ${{ env.WORK_DIR }}
127131
run: |
128132
$ErrorActionPreference = 'Stop'
129-
cp "$env:OPEN3D_DIR/3rdparty/webrtc/CMakeLists.txt" webrtc/
130-
cp "$env:OPEN3D_DIR/3rdparty/webrtc/webrtc_common.cmake" webrtc/
131-
132-
- name: Build WebRTC (Release)
133-
working-directory: ${{ env.WORK_DIR }}
134-
run: |
135-
$ErrorActionPreference = 'Stop'
136-
$env:Path = (Get-Item depot_tools).FullName + ";" + $env:Path
137-
mkdir webrtc/build
138-
cd webrtc/build
139-
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release `
140-
-D CMAKE_INSTALL_PREFIX=${{ env.WORK_DIR }}/webrtc_release/Release `
141-
..
142-
ninja install
143-
echo "Cleanup build folder for next config build"
144-
cd ..
145-
rm -r build
133+
Copy-Item "$env:OPEN3D_DIR/3rdparty/webrtc/CMakeLists.txt" webrtc/
134+
Copy-Item "$env:OPEN3D_DIR/3rdparty/webrtc/webrtc_common.cmake" webrtc/
135+
bash "$env:OPEN3D_DIR/3rdparty/webrtc/apply_webrtc_patches.sh" `
136+
"$env:OPEN3D_DIR" "$env:WORK_DIR/webrtc/src"
146137
147-
- name: Build WebRTC (Debug)
138+
- name: Build and package WebRTC
139+
shell: pwsh
148140
working-directory: ${{ env.WORK_DIR }}
141+
env:
142+
BUILD_CONFIG: ${{ matrix.config }}
143+
STATIC_RT: ${{ matrix.static_runtime }}
144+
WIN_TAG: ${{ matrix.tag }}
149145
run: |
150146
$ErrorActionPreference = 'Stop'
151-
$env:Path = (Get-Item depot_tools).FullName + ";" + $env:Path
152-
mkdir webrtc/build
153-
cd webrtc/build
154-
cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug `
155-
-D CMAKE_INSTALL_PREFIX=${{ env.WORK_DIR }}/webrtc_release/Debug `
156-
..
147+
# Locate the VS-installed ninja.exe *before* prepending depot_tools to
148+
# PATH. depot_tools contains a Unix wrapper script named 'ninja' (no
149+
# extension) that Windows cannot execute; if depot_tools appears first
150+
# in PATH cmake -G Ninja picks up that script and fails with
151+
# "unknown error" when trying to run 'ninja --version'.
152+
$ninjaExe = (Get-Command ninja.exe -ErrorAction Stop).Source
153+
$env:Path = (Get-Item depot_tools).FullName + ';' + $env:Path
154+
$installRoot = Join-Path $env:WORK_DIR "webrtc_pkg"
155+
if (Test-Path $installRoot) { Remove-Item -Recurse -Force $installRoot }
156+
New-Item -ItemType Directory -Force -Path webrtc/build | Out-Null
157+
Push-Location webrtc/build
158+
$debugFlag = if ($env:BUILD_CONFIG -eq 'Debug') { 'ON' } else { 'OFF' }
159+
cmake -G Ninja `
160+
-D CMAKE_MAKE_PROGRAM="$ninjaExe" `
161+
-D CMAKE_BUILD_TYPE=$env:BUILD_CONFIG `
162+
-D WEBRTC_IS_DEBUG=$debugFlag `
163+
-D WEBRTC_STATIC_MSVC_RUNTIME=$env:STATIC_RT `
164+
-D CMAKE_INSTALL_PREFIX=$installRoot `
165+
..
157166
ninja install
158-
159-
- name: Package WebRTC
160-
working-directory: ${{ env.WORK_DIR }}
161-
run: |
162-
$ErrorActionPreference = 'Stop'
163-
$env:WEBRTC_COMMIT_SHORT = (git -C webrtc/src rev-parse --short=7 HEAD)
164-
cmake -E tar cv webrtc_${env:WEBRTC_COMMIT_SHORT}_win.zip `
165-
--format=zip -- webrtc_release
166-
cmake -E sha256sum webrtc_${env:WEBRTC_COMMIT_SHORT}_win.zip | Tee-Object -FilePath checksum_win.txt
167+
Pop-Location
168+
$short = (git -C webrtc/src rev-parse --short=7 HEAD)
169+
$zip = "webrtc_${short}_win_$env:WIN_TAG.zip"
170+
Push-Location $installRoot
171+
cmake -E tar cvf (Join-Path $env:OPEN3D_DIR $zip) --format=zip .
172+
Pop-Location
173+
cmake -E sha256sum (Join-Path $env:OPEN3D_DIR $zip) | Tee-Object -FilePath (Join-Path $env:OPEN3D_DIR "checksum_$zip")
167174
168175
- name: Upload WebRTC
169176
uses: actions/upload-artifact@v4
170177
with:
171-
name: webrtc_release_windows
178+
name: webrtc_win_${{ matrix.tag }}
172179
path: |
173-
${{ env.WORK_DIR }}/webrtc_*.zip
174-
${{ env.WORK_DIR }}/checksum_*.txt
180+
webrtc_*_win_*.zip
181+
checksum_webrtc_*_win_*.zip
175182
if-no-files-found: error

.github/workflows/windows.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ jobs:
5656
- BUILD_CUDA_MODULE: ON # FIXME
5757
CONFIG: Debug
5858
env:
59-
BUILD_WEBRTC: ${{ ( matrix.BUILD_SHARED_LIBS == 'OFF' && matrix.STATIC_RUNTIME == 'ON' ) && 'ON' || 'OFF' }}
6059
BUILD_PYTORCH_OPS: ${{ ( matrix.BUILD_CUDA_MODULE == 'ON' || matrix.CONFIG == 'Debug' ) && 'OFF' || 'ON' }} # FIXME
6160

6261
steps:
@@ -145,7 +144,6 @@ jobs:
145144
-DSTATIC_WINDOWS_RUNTIME=${{ matrix.STATIC_RUNTIME }} `
146145
-DBUILD_COMMON_ISPC_ISAS=ON `
147146
-DBUILD_LIBREALSENSE=ON `
148-
-DBUILD_WEBRTC=${{ env.BUILD_WEBRTC }} `
149147
-DBUILD_UNIT_TESTS=ON `
150148
-DBUILD_CUDA_MODULE=${{ matrix.BUILD_CUDA_MODULE }} `
151149
-DBUILD_PYTORCH_OPS=${{ env.BUILD_PYTORCH_OPS }} `
@@ -361,7 +359,6 @@ jobs:
361359
-DBUILD_COMMON_ISPC_ISAS=ON `
362360
-DBUILD_AZURE_KINECT=ON `
363361
-DBUILD_LIBREALSENSE=ON `
364-
-DBUILD_WEBRTC=ON `
365362
-DBUILD_JUPYTER_EXTENSION=ON `
366363
-DBUILD_PYTORCH_OPS=${{ env.BUILD_PYTORCH_OPS }} `
367364
${{ env.SRC_DIR }}

3rdparty/find_dependencies.cmake

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,11 +1988,43 @@ if(BUILD_WEBRTC)
19881988
open3d_import_3rdparty_library(3rdparty_webrtc
19891989
HIDDEN
19901990
INCLUDE_DIRS ${WEBRTC_INCLUDE_DIRS}
1991-
LIB_DIR ${WEBRTC_LIB_DIR}
1992-
LIBRARIES ${WEBRTC_LIBRARIES}
19931991
DEPENDS ext_webrtc_all
19941992
)
1993+
# webrtc/webrtc_extra need custom --whole-archive handling (below), so
1994+
# they can't use open3d_import_3rdparty_library()'s LIBRARIES option.
1995+
# Install them manually and reference $<INSTALL_INTERFACE:...> paths, so
1996+
# examples built against an installed *static* Open3D package (i.e. not
1997+
# from within this build tree) still link against them; see the
1998+
# LIBRARIES branch of open3d_import_3rdparty_library() for reference.
1999+
if(NOT BUILD_SHARED_LIBS)
2000+
foreach(_o3d_webrtc_lib webrtc webrtc_extra)
2001+
install(FILES "${WEBRTC_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${_o3d_webrtc_lib}${CMAKE_STATIC_LIBRARY_SUFFIX}"
2002+
DESTINATION ${Open3D_INSTALL_LIB_DIR}
2003+
RENAME "${CMAKE_STATIC_LIBRARY_PREFIX}${PROJECT_NAME}_3rdparty_webrtc_${_o3d_webrtc_lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
2004+
endforeach()
2005+
endif()
2006+
set(WEBRTC_INSTALLED_LIB
2007+
"$<INSTALL_PREFIX>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROJECT_NAME}_3rdparty_webrtc")
2008+
if(UNIX AND NOT APPLE)
2009+
target_link_libraries(3rdparty_webrtc INTERFACE
2010+
"-Wl,--whole-archive"
2011+
"$<BUILD_INTERFACE:${WEBRTC_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_LIBRARY_SUFFIX}>"
2012+
"$<INSTALL_INTERFACE:${WEBRTC_INSTALLED_LIB}_webrtc${CMAKE_STATIC_LIBRARY_SUFFIX}>"
2013+
"-Wl,--no-whole-archive"
2014+
"$<BUILD_INTERFACE:${WEBRTC_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc_extra${CMAKE_STATIC_LIBRARY_SUFFIX}>"
2015+
"$<INSTALL_INTERFACE:${WEBRTC_INSTALLED_LIB}_webrtc_extra${CMAKE_STATIC_LIBRARY_SUFFIX}>")
2016+
else()
2017+
target_link_libraries(3rdparty_webrtc INTERFACE
2018+
"$<BUILD_INTERFACE:${WEBRTC_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc${CMAKE_STATIC_LIBRARY_SUFFIX}>"
2019+
"$<INSTALL_INTERFACE:${WEBRTC_INSTALLED_LIB}_webrtc${CMAKE_STATIC_LIBRARY_SUFFIX}>"
2020+
"$<BUILD_INTERFACE:${WEBRTC_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}webrtc_extra${CMAKE_STATIC_LIBRARY_SUFFIX}>"
2021+
"$<INSTALL_INTERFACE:${WEBRTC_INSTALLED_LIB}_webrtc_extra${CMAKE_STATIC_LIBRARY_SUFFIX}>")
2022+
endif()
19952023
target_link_libraries(3rdparty_webrtc INTERFACE Open3D::3rdparty_threads ${CMAKE_DL_LIBS})
2024+
# libwebrtc.a and libturbojpeg.a both export jpeg_* symbols (WebRTC bundles libjpeg).
2025+
if(UNIX AND NOT APPLE)
2026+
target_link_options(3rdparty_webrtc INTERFACE "LINKER:--allow-multiple-definition")
2027+
endif()
19962028
if (MSVC) # https://github.com/iimachines/webrtc-build/issues/2#issuecomment-503535704
19972029
target_link_libraries(3rdparty_webrtc INTERFACE secur32 winmm dmoguids wmcodecdspuuid msdmo strmiids)
19982030
endif()
Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1-
From c47a1b6c0faa2206395647cb83cb1a0542101847 Mon Sep 17 00:00:00 2001
2-
From: Yixing Lao <yixing.lao@gmail.com>
3-
Date: Wed, 7 Apr 2021 16:17:39 -0700
4-
Subject: [PATCH] build: enable rtc_use_cxx11_abi option
5-
6-
---
7-
config/BUILDCONFIG.gn | 6 ++++++
8-
1 file changed, 6 insertions(+)
9-
101
diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn
11-
index 0ef73ab2b..5ab677e27 100644
122
--- a/config/BUILDCONFIG.gn
133
+++ b/config/BUILDCONFIG.gn
14-
@@ -163,6 +163,12 @@ declare_args() {
15-
is_component_build = is_debug && current_os != "ios"
4+
@@ -171,6 +171,11 @@ declare_args() {
5+
is_debug && current_os != "ios" && current_os != "watchos"
166
}
177

188
+declare_args() {
19-
+ # Set to false to define "_GLIBCXX_USE_CXX11_ABI=0". If set to true, the
20-
+ # default will be used, which corresponds to the new CXX11 ABI.
9+
+ # Open3D: GCC libstdc++ ABI selection on Linux.
2110
+ rtc_use_cxx11_abi = true
2211
+}
2312
+
2413
assert(!(is_debug && is_official_build), "Can't do official debug builds")
25-
26-
# ==============================================================================
27-
--
28-
2.17.1
29-
14+
assert(!(current_os == "ios" && is_component_build),
15+
"Can't use component build on iOS")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/rtc_base/ssl_stream_adapter.h b/rtc_base/ssl_stream_adapter.h
2+
--- a/rtc_base/ssl_stream_adapter.h
3+
+++ b/rtc_base/ssl_stream_adapter.h
4+
@@ -129,7 +129,7 @@ class SSLStreamAdapter : public StreamInterface {
5+
static std::unique_ptr<SSLStreamAdapter> Create(
6+
std::unique_ptr<StreamInterface> stream,
7+
absl::AnyInvocable<void(SSLHandshakeError)> handshake_error,
8+
- nullptr_t /*field_trials*/) {
9+
+ std::nullptr_t /*field_trials*/) {
10+
return Create(std::move(stream), std::move(handshake_error));
11+
}
12+

0 commit comments

Comments
 (0)