SciChart iOS v2.x API > Advanced 2D Charting Topics > Enabling Metal support in SciChart iOS
Enabling Metal support in SciChart iOS

Since August 2018, Apple has announced that they are deprecating OpenGL ES across iOS and OSX devices, in favour of Metal, a proprietary graphics API.

From the page https://developer.apple.com/macos/whats-new/

Deprecation of OpenGL and OpenCL

Apps built using OpenGL and OpenCL will continue to run in macOS 10.14, but these legacy technologies are deprecated in macOS 10.14. Games and graphics-intensive apps that use OpenGL should now adopt Metal. Similarly, apps that use OpenCL for computational tasks should now adopt Metal and Metal Performance Shaders.

Metal is designed from the ground up to provide the best access to the modern GPUs on iOS, macOS, and tvOS devices. Metal avoids the overhead inherent in legacy technologies and exposes the latest graphics processing functionality. Unified support for graphics and compute in Metal lets your apps efficiently utilize the latest rendering techniques.

 

SciChart iOS is built on top of a hardware-accelerated API called OpenGL ES, and as of SciChart iOS v2.5, we now support Metal as well.

To enable Metal in your application, use this code:

// Enable Metal
sciChartSurface.renderSurface = [[SCIMetalRenderSurface alloc] initWithFrame:sciChartSurface.bounds];

// Switch back to OpenGL ES
sciChartSurface.renderSurface = [[SCIOpenGLRenderSurface alloc] initWithFrame:sciChartSurface.bounds];
// Enable Metal 
sciChartSurface.renderSurface = SCIMetalRenderSurface(frame: sciChartSurface.bounds) 

// Switch back to OpenGL
sciChartSurface.renderSurface = SCIOpenGLRenderSurface(frame: sciChartSurface.bounds) 
// Enable Metal
sciChartSurface.RenderSurface = new SCIMetalRenderSurface(sciChartSurface.Bounds);

// Switch back to OpenGL
sciChartSurface.RenderSurface = new SCIOpenGLRenderSurface(sciChartSurface.Bounds);

 

Auto Detect Metal Support

By default, the OpenGL ES rendering pathway is enabled for SciChart.iOS and is currently supported by all current iOS devices. However, in the future this might change.

We recommend auto-detecting metal support on the target device, so that older devices without Metal-capable GPUs can still use SciChart iOS.

 

// Detect metal with this static property 
if (SCIChartSurface.isMetalSupported) {
  // Apply it to the instance of the chart. 
  // OpenGL is the default so there is no need for an else-clause
  sciChartSurface.renderSurface = [[SCIMetalRenderSurface alloc] initWithFrame:surface.bounds];
}
// Detect metal with this static property 
if (SCIChartSurface.isMetalSupported) {
  // Apply it to the instance of the chart. 
  // OpenGL is the default so there is no need for an else-clause
  surface.renderSurface = SCIMetalRenderSurface(frame: surface.bounds) 
}
// Detect metal with this static property 
if (SCIChartSurfaceView.IsMetalSupported) {
  // Apply it to the instance of the chart. 
  // OpenGL is the default so there is no need for an else-clause
  surface.RenderSurface = new SCIMetalRenderSurface(surface.Bounds);
}

 

Metal FAQS

Q: Are there any feature differences between OpenGL ES & Metal RenderSurface in SciChart?

A: No, none at all. They do fundamentally the same things.

If you encounter a case where Metal doesn't render properly, or has visual glitches, then contact our support team and let us know how to reproduce it, so we can fix it.

 

Q: Are there any performance differences between OpenGL ES and Metal SciChart?

A: Also no, our performance tests show that Metal is comparable to OpenGL performance (Sometimes slightly faster, sometimes slightly slower).

If you encounter a case where Metal is noticebly slower than OpenGL ES, then contact our support team and let us know how to reproduce it, so that we can optimise.

 

Q: Why is my chart blank in the Simulator?

A: At the moment iOS Simulators do not support Metal, only OpenGL ES. We recommend using the OpenGL rendering pathway in the simulator until Apple changes this.