Performance Optimization
Relevant source files
The following files were used as context for generating this wiki page:
Performance optimization in the Nextcloud CAD Viewer involves a multi-layered approach targeting server-side resource management, client-side hardware utilization, and drawing-specific adjustments. The primary goal is to ensure smooth rendering of DWG and DXF files using WebGL technology, particularly when handling large datasets or complex architectural drawings.
The system relies on browser-based rendering using the @mlightcad/cad-viewer library, which shifts the heavy lifting of visualization from the server to the client's GPU. Effective performance is achieved through a combination of proper server configuration, modern browser features like hardware acceleration, and user-led optimizations such as layer management. For more information on environmental needs, see the Requirements section.
Sources: README.md:12-19, wiki/Requirements.md:144-154, src/App.vue:1-12
Server-Side Optimization
The server's role in the CAD Viewer performance is primarily focused on file streaming, caching, and handling concurrent requests. Efficiently delivering large CAD files to the client's browser is critical for the initial load experience.
Resource Allocation
To maintain high performance, the server requires sufficient CPU and RAM to manage file I/O operations and PHP execution for the Nextcloud environment.
| Resource | Minimum | Recommended | Impact |
|---|---|---|---|
| CPU | 2 cores | 4+ cores | Improves file streaming and concurrent user handling |
| RAM | 2 GB | 4-8 GB | Allows for larger file caching (approx. 2GB per heavy user) |
| Storage | HDD | SSD | Significantly reduces initial file load times |
| Bandwidth | 10 Mbps | 100 Mbps+ | Reduces latency for downloading large DWG/DXF files |
Sources: wiki/Requirements.md:57-76, wiki/Requirements.md:157-164
PHP and Caching Configuration
Nextcloud CAD Viewer performance is enhanced by optimizing the PHP environment and enabling server-side caching mechanisms.
- Memory Limit: A minimum of 512MB is required, but 1GB is recommended for processing large files.
- Execution Time:
max_execution_timeshould be set to at least 120 seconds (300 recommended) to prevent timeouts during large file reads. - OPcache: Using PHP OPcache is highly recommended to improve script execution speed.
- Distributed Caching: Administrators should configure Redis or Memcached within Nextcloud to handle metadata and session caching.
Sources: wiki/Requirements.md:23-30, wiki/Requirements.md:173-177, wiki/Installation-Guide.md:167-172
Client-Side and Browser Optimization
Since the rendering engine is fully web-based, the client's hardware and browser configuration are the most significant factors in navigation smoothness (zoom/pan) and rendering speed.
Hardware Acceleration
The viewer uses WebGL 2.0 for 3D and 2D rendering. Performance is heavily dependent on the client's GPU.
- GPU Utilization: A dedicated GPU is recommended for complex drawings, though integrated graphics are sufficient for simpler files.
- Browser Settings: Hardware acceleration must be enabled in browser settings (e.g.,
Settings → System → Use hardware accelerationin Chrome).
Sources: wiki/Requirements.md:104-106, wiki/Requirements.md:130-141, wiki/Troubleshooting.md:189-192
Rendering Workflow
The following diagram illustrates the flow from the user request to the hardware-accelerated rendering on the client side.
The application initializes the viewer via src/App.vue, which utilizes the loadCADViewer utility to hook into the WebGL canvas.
Sources: src/App.vue:43-57, wiki/Requirements.md:104-106, README.md:46-54
Drawing Management and UI Techniques
Users can optimize performance dynamically while interacting with the viewer by managing the complexity of the data currently being processed by the GPU.
Layer Visibility Management
The Layer Manager allows users to toggle the visibility of specific elements. This is the most effective way to improve performance on complex drawings without modifying the source file.
- Clutter Reduction: Hiding unnecessary layers (e.g., dimensions, construction lines, or text) reduces the number of draw calls required by the WebGL engine.
- Focus: By isolating specific layers, the viewer processes fewer vertices, leading to smoother pan and zoom operations.
Sources: wiki/User-Guide.md:105-120, wiki/User-Guide.md:204-206
Efficient Navigation
The application provides several built-in controls to maintain performance during navigation:
- Fit to View: Using the 'F' shortcut or the Fit button resets the viewport, which can help if the engine becomes sluggish due to extreme zoom levels.
- Memory Management: Large files consume significant browser memory. Users are advised to close unused tabs to free up RAM for the WebGL context.
Sources: wiki/User-Guide.md:197-201, wiki/Troubleshooting.md:214-216
Optimization Checklist for Administrators
| Action | Component | Configuration |
|---|---|---|
| Enable Gzip/Brotli | Web Server | Reduces transfer size of static assets and CAD data |
| Configure CDN | Network | Recommended for distributed user bases to reduce latency |
| Update PHP | Runtime | Ensure PHP 8.2+ is used for better performance and security |
| SSD Storage | Hardware | Essential for high-speed I/O with 100MB+ CAD files |
Sources: wiki/Requirements.md:14-22, wiki/Requirements.md:173-177, README.md:22-26
Summary
Performance Optimization in Nextcloud CAD Viewer is centered on efficient data delivery from the server and high-performance WebGL rendering on the client. By ensuring that the client machine has hardware acceleration enabled and the server is configured with adequate PHP memory limits and caching (Redis/OPcache), the app can handle DWG/DXF files up to 500MB. Users further enhance this experience by utilizing the layer manager to reduce drawing complexity during active sessions.
Sources: wiki/Requirements.md:157-180, wiki/Troubleshooting.md:201-224