From 7fcdad487ebbe1debfa4e56eb131466fd10cb2e2 Mon Sep 17 00:00:00 2001 From: Sameer Sheorey Date: Tue, 7 Jan 2025 12:38:10 -0800 Subject: [PATCH] Fix GLFW platform selection when re-initialized. GLFW remembers last null platform. --- .../visualization/visualizer/Visualizer.cpp | 14 +-- docker/Dockerfile.docs | 98 ------------------- 2 files changed, 8 insertions(+), 104 deletions(-) delete mode 100755 docker/Dockerfile.docs diff --git a/cpp/open3d/visualization/visualizer/Visualizer.cpp b/cpp/open3d/visualization/visualizer/Visualizer.cpp index 4986cf6d0d0..85c87fb02f4 100644 --- a/cpp/open3d/visualization/visualizer/Visualizer.cpp +++ b/cpp/open3d/visualization/visualizer/Visualizer.cpp @@ -34,13 +34,14 @@ class GLFWContext { // framework build version of Python. glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE); #endif - if (!(init_status_ = glfwInit())) { + init_status_ = glfwInit(); + if (init_status_ != GLFW_TRUE) { glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL); init_status_ = glfwInit(); - if (init_status_ == GLFW_TRUE) { - init_status_ = GLFW_PLATFORM_NULL; - utility::LogWarning("GLFW initialized for headless rendering."); - } + } + if (init_status_ == GLFW_TRUE) init_status_ = glfwGetPlatform(); + if (init_status_ == GLFW_PLATFORM_NULL) { + utility::LogWarning("GLFW initialized for headless rendering."); } } @@ -51,11 +52,12 @@ class GLFWContext { ~GLFWContext() { if (init_status_ != GLFW_FALSE) { glfwTerminate(); + init_status_ = GLFW_FALSE; utility::LogDebug("GLFW destruct."); } } - /// \brief Get the glfwInit status. + /// \brief Get the glfwInit status / GLFW_PLATFORM initialized. inline int InitStatus() const { return init_status_; } /// \brief Get a shared instance of the GLFW context. diff --git a/docker/Dockerfile.docs b/docker/Dockerfile.docs deleted file mode 100755 index 5dd9dae51af..00000000000 --- a/docker/Dockerfile.docs +++ /dev/null @@ -1,98 +0,0 @@ -# FROM must be called before other ARGS except for ARG BASE_IMAGE -ARG BASE_IMAGE -FROM ${BASE_IMAGE} - -# For bash-specific commands -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# Required build args, should be specified in docker_build.sh -ARG DEVELOPER_BUILD -ARG PYTHON_VERSION -ARG CI - -RUN if [[ -z "${DEVELOPER_BUILD}" ]]; then echo "Error: ARG DEVELOPER_BUILD not specified."; exit 1; fi \ - && if [[ -z "${PYTHON_VERSION}" ]]; then echo "Error: ARG PYTHON_VERSION not specified."; exit 1; fi - -# Forward all ARG to ENV -# ci_utils.sh may require these environment variables -ENV DEVELOPER_BUILD=${DEVELOPER_BUILD} -ENV PYTHON_VERSION=${PYTHON_VERSION} - -# Prevent interactive inputs when installing packages -ENV DEBIAN_FRONTEND=noninteractive -ENV TZ=America/Los_Angeles -ENV SUDO=command -ENV OPEN3D_ML_ROOT=/root/Open3D-ML - -# Always keep /root/Open3D as the WORKDIR -WORKDIR /root/Open3D -COPY util/ci_utils.sh util/install_deps_ubuntu.sh util/ -COPY python/requirements*.txt python/ -COPY docs/requirements.txt docs/ - -# Dependencies: basic and python-build -RUN apt-get update && apt-get install -y \ - git \ - curl \ - build-essential \ - pkg-config \ - zlib1g \ - zlib1g-dev \ - libssl-dev \ - libbz2-dev \ - libreadline-dev \ - libsqlite3-dev \ - libncursesw5-dev \ - xz-utils \ - tk-dev \ - libxml2-dev \ - libxmlsec1-dev \ - libffi-dev \ - liblzma-dev \ - && rm -rf /var/lib/apt/lists/* - -# Checkout Open3D-ML main branch -RUN git clone --depth 1 https://github.com/isl-org/Open3D-ML.git ${OPEN3D_ML_ROOT} -# Open3D docs dependencies -RUN source util/ci_utils.sh && install_docs_dependencies "${OPEN3D_ML_ROOT}" - -# Download ccache from GCS bucket -# If it doesn't exist on the cloud, an empty ${CCACHE_DIR} will be created. -# Example directory structure: -# - CCACHE_DIR = ~/.cache/ccache -# - CCACHE_DIR_NAME = ccache -# - CCACHE_DIR_PARENT = ~/.cache -# We need to set ccache size explicitly with -M, otherwise the defualt size is -# *not* determined by ccache's default, but the downloaded ccache file's config. -RUN CCACHE_DIR=$(ccache -p | grep cache_dir | grep -oE "[^ ]+$") \ - && CCACHE_DIR_NAME=$(basename ${CCACHE_DIR}) \ - && CCACHE_DIR_PARENT=$(dirname ${CCACHE_DIR}) \ - && CCACHE_TAR_NAME="open3d-ci-cpu" \ - && mkdir -p ${CCACHE_DIR_PARENT} \ - && cd ${CCACHE_DIR_PARENT} \ - && (curl -s -O https://storage.googleapis.com/open3d-ci-cache/${CCACHE_TAR_NAME}.tar.xz || true) \ - && if [ -f ${CCACHE_TAR_NAME}.tar.xz ]; then tar -xf ${CCACHE_TAR_NAME}.tar.xz || true; fi \ - && mkdir -p ${CCACHE_DIR} \ - && ccache -M 4G \ - && ccache -s - -# Open3D repo -COPY . /root/Open3D - -# PWD: Open3D/docs after build_docs -# Docs in docs/_out/html -RUN source util/ci_utils.sh && build_docs "$DEVELOPER_BUILD" \ -&& ccache -s \ -tar -C _out -cvzf "/root/Open3D/open3d-$(git rev-parse HEAD)-docs.tar.gz" html - -# Compress ccache folder, move to / directory -RUN ccache -s \ - && CCACHE_DIR=$(ccache -p | grep cache_dir | grep -oE "[^ ]+$") \ - && CCACHE_DIR_NAME=$(basename ${CCACHE_DIR}) \ - && CCACHE_DIR_PARENT=$(dirname ${CCACHE_DIR}) \ - && cd ${CCACHE_DIR_PARENT} \ - && tar -caf /${CCACHE_TAR_NAME}.tar.xz ${CCACHE_DIR_NAME} \ - && mv /root/Open3D/build/package/open3d-devel*.tar.xz /; fi \ - && ls -alh / - -RUN echo "Docker documentation build done."