Skip to content
Merged
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
5 changes: 5 additions & 0 deletions crates/utils/re_analytics/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ pub struct ViewerStarted {

/// Some sparse information about the runtime environment the viewer is running in.
pub struct ViewerRuntimeInformation {
/// Does it look like the viewer is running inside a Docker container?
pub is_docker: bool,

/// Whether the viewer is started directly from within Windows Subsystem for Linux (WSL).
pub is_wsl: bool,

Expand All @@ -82,11 +85,13 @@ pub struct ViewerRuntimeInformation {
impl Properties for ViewerRuntimeInformation {
fn serialize(self, event: &mut AnalyticsEvent) {
let Self {
is_docker,
is_wsl,
graphics_adapter_backend,
re_renderer_device_tier,
} = self;

event.insert("is_docker", is_docker);
event.insert("is_wsl", is_wsl);
event.insert("graphics_adapter_backend", graphics_adapter_backend);
event.insert("re_renderer_device_tier", re_renderer_device_tier);
Expand Down
31 changes: 31 additions & 0 deletions crates/viewer/re_viewer/src/docker_detection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// Detect if the application is running inside a Docker container
#[cfg(target_os = "linux")]
pub fn is_docker() -> bool {
/// Check for the presence of /.dockerenv file (most reliable method)
fn is_dockerenv_present() -> bool {
std::path::Path::new("/.dockerenv").exists()
}

/// Check if 'docker' appears in cgroup information
fn is_docker_in_cgroup() -> bool {
// Try multiple cgroup paths
let cgroup_paths = ["/proc/1/cgroup", "/proc/self/cgroup"];

for path in &cgroup_paths {
if let Ok(contents) = std::fs::read_to_string(path) {
if contents.contains("docker") {
return true;
}
}
}
false
}

is_dockerenv_present() || is_docker_in_cgroup()
}

/// Detect if the application is running inside a Docker container
#[cfg(not(target_os = "linux"))]
pub fn is_docker() -> bool {
false
}
1 change: 1 addition & 0 deletions crates/viewer/re_viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod app_blueprint;
mod app_state;
mod background_tasks;
mod default_views;
mod docker_detection;
pub mod env_vars;
pub mod event;
mod navigation;
Expand Down
6 changes: 6 additions & 0 deletions crates/viewer/re_viewer/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ pub fn run_native_app(
app_creator: AppCreator,
force_wgpu_backend: Option<&str>,
) -> eframe::Result {
if crate::docker_detection::is_docker() {
re_log::warn_once!(
"It looks like you are running the Rerun Viewer inside a Docker container. This is not officially supported, and may lead to performance issues and bugs. See https://github.com/rerun-io/rerun/issues/6835 for more.",
);
}

let native_options = eframe_options(force_wgpu_backend);

let window_title = "Rerun Viewer";
Expand Down
1 change: 1 addition & 0 deletions crates/viewer/re_viewer/src/viewer_analytics/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub fn viewer_started(
url: app_env.url().cloned(),
app_env: app_env.name(),
runtime_info: ViewerRuntimeInformation {
is_docker: crate::docker_detection::is_docker(),
is_wsl: super::wsl::is_wsl(),
graphics_adapter_backend: adapter_backend.to_string(),
re_renderer_device_tier: device_tier.to_string(),
Expand Down
Loading