diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp index 7b20407cca..0d3104c1ab 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.cpp @@ -225,4 +225,16 @@ ComponentPeer* AudioProcessorEditor::createNewPeer ([[maybe_unused]] int styleFl return Component::createNewPeer (styleFlags, nativeWindow); } +bool AudioProcessorEditor::wantsLayerBackedView() const +{ + #if JUCE_MODULE_AVAILABLE_juce_opengl && JUCE_MAC + if (@available (macOS 10.14, *)) + return true; + + return false; + #else + return true; + #endif +} + } // namespace juce diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h index df43af6421..3bc5e3ac4d 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorEditor.h @@ -206,6 +206,23 @@ public: */ std::unique_ptr resizableCorner; + /** The plugin wrapper will call this function to decide whether to use a layer-backed view to + host the editor on macOS and iOS. + + Layer-backed views generally provide better performance, and are recommended in most + situations. However, on older macOS versions (confirmed on 10.12 and 10.13), displaying an + OpenGL context inside a layer-backed view can lead to deadlocks, so it is recommended to + avoid layer-backed views when using OpenGL on these OS versions. + + The default behaviour of this function is to return false if and only if the juce_opengl + module is present and the current platform is macOS 10.13 or earlier. + + You may want to override this behaviour if your plugin has an option to enable and disable + OpenGL rendering. If you know your plugin editor will never use OpenGL rendering, you can + set this function to return true in all situations. + */ + virtual bool wantsLayerBackedView() const; + private: //============================================================================== struct AudioProcessorEditorListener : public ComponentListener