--- qtwebengine/src/core/web_engine_context.cpp
+++ qtwebengine/src/core/web_engine_context.cpp
@@ -347,6 +347,12 @@
         parsedCommandLine->AppendSwitchASCII(switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
     }

+    parsedCommandLine->AppendSwitch(switches::kEnableViewport);
+#if defined(Q_OS_WIN)
+    parsedCommandLine->AppendSwitch(switches::kDisableGpu);
+#endif
+    parsedCommandLine->AppendSwitch(switches::kDisableWebSecurity);
+
     GLContextHelper::initialize();

     const char *glType = 0;
@@ -389,8 +395,10 @@
                     }
                 }
             } else {
+                QSurfaceFormat format = qt_gl_global_share_context()->format();
+                // NOTE: kGLImplementationDesktopGLCoreProfileName is only implemented on macOS at the moment
                 if (!qt_gl_global_share_context()->isOpenGLES())
-                    glType = gl::kGLImplementationDesktopName;
+                    glType = format.majorVersion() < 3 ? gl::kGLImplementationDesktopName : gl::kGLImplementationDesktopGLCoreProfileName;
             }
         } else {
             qWarning("WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.");
--- qtbase/src/plugins/platforms/cocoa/qnsview.mm
+++ qtbase/src/plugins/platforms/cocoa/qnsview.mm
@@ -563,7 +563,7 @@
         return NO;
     if ([self isTransparentForUserInput])
         return NO;
-    return YES;
+    return NO;
 }

 - (NSView *)hitTest:(NSPoint)aPoint
--- qtbase/src/gui/kernel/qsurfaceformat.cpp
+++ qtbase/src/gui/kernel/qsurfaceformat.cpp
@@ -110,6 +110,7 @@
     int major;
     int minor;
     int swapInterval;
+    QSurfaceFormat::OrientationFlags orientationFlags;
 };

 /*!
@@ -736,6 +737,16 @@
     return d->swapInterval;
 }

+QSurfaceFormat::OrientationFlags QSurfaceFormat::orientationFlags() const
+{
+    return d->orientationFlags;
+}
+
+void QSurfaceFormat::setOrientationFlags(QSurfaceFormat::OrientationFlags orientationFlags)
+{
+    d->orientationFlags = orientationFlags;
+}
+
 Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)

 /*!
--- qtbase/src/gui/kernel/qsurfaceformat.h
+++ qtbase/src/gui/kernel/qsurfaceformat.h
@@ -57,7 +57,8 @@
         StereoBuffers            = 0x0001,
         DebugContext             = 0x0002,
         DeprecatedFunctions      = 0x0004,
-        ResetNotification        = 0x0008
+        ResetNotification        = 0x0008,
+        UseOptimalOrientation    = 0x0010
     };
     Q_ENUM(FormatOption)
     Q_DECLARE_FLAGS(FormatOptions, FormatOption)
@@ -85,6 +86,11 @@
     };
     Q_ENUM(OpenGLContextProfile)

+    enum OrientationFlag {
+        MirrorVertically = 0x0001,
+    };
+    Q_DECLARE_FLAGS(OrientationFlags, OrientationFlag)
+
     QSurfaceFormat();
     /*implicit*/ QSurfaceFormat(FormatOptions options);
     QSurfaceFormat(const QSurfaceFormat &other);
@@ -145,6 +151,9 @@
     int swapInterval() const;
     void setSwapInterval(int interval);

+    QSurfaceFormat::OrientationFlags orientationFlags() const;
+    void setOrientationFlags(QSurfaceFormat::OrientationFlags orientationFlags);
+
     static void setDefaultFormat(const QSurfaceFormat &format);
     static QSurfaceFormat defaultFormat();

--- qtbase/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ qtbase/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -297,11 +297,25 @@
     return new QWindowsEGLContext(this, context->format(), context->shareHandle());
 }

-void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, int *err)
+void *QWindowsEGLStaticContext::createWindowSurface(void *nativeWindow, void *nativeConfig, const QSurfaceFormat format, int *err)
 {
     *err = 0;
+
+    std::vector<EGLint> attrib_list;
+#ifdef EGL_ANGLE_surface_orientation
+    if (format.testOption(QSurfaceFormat::UseOptimalOrientation)) {
+        EGLint surfaceOrientation = 0;
+        libEGL.eglGetConfigAttrib(m_display, nativeConfig, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &surfaceOrientation);
+        if (surfaceOrientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE) {
+            attrib_list.push_back(EGL_SURFACE_ORIENTATION_ANGLE);
+            attrib_list.push_back(EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE);
+        }
+    }
+#endif
+    attrib_list.push_back(EGL_NONE);
     EGLSurface surface = libEGL.eglCreateWindowSurface(m_display, nativeConfig,
-                                                       static_cast<EGLNativeWindowType>(nativeWindow), 0);
+                                                       static_cast<EGLNativeWindowType>(nativeWindow),
+                                                       &attrib_list[0]);
     if (surface == EGL_NO_SURFACE) {
         *err = libEGL.eglGetError();
         qWarning("%s: Could not create the EGL window surface: 0x%x", __FUNCTION__, *err);
@@ -350,6 +364,14 @@
     format.setStereo(false);
     format.setSwapInterval(referenceFormat.swapInterval());

+#ifdef EGL_ANGLE_surface_orientation
+    if (referenceFormat.testOption(QSurfaceFormat::UseOptimalOrientation)) {
+        EGLint surfaceOrientation = 0;
+        libEGL.eglGetConfigAttrib(display, config, EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &surfaceOrientation);
+        format.setOrientationFlags((surfaceOrientation & EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE) ? QSurfaceFormat::MirrorVertically : QSurfaceFormat::OrientationFlags());
+    }
+#endif
+
     // Clear the EGL error state because some of the above may
     // have errored out because the attribute is not applicable
     // to the surface type.  Such errors don't matter.
@@ -443,7 +465,7 @@
             }
         }
         m_format.setProfile(QSurfaceFormat::NoProfile);
-        m_format.setOptions(QSurfaceFormat::FormatOptions());
+        m_format.setOptions(m_format.options() & QSurfaceFormat::UseOptimalOrientation);
         QWindowsEGLStaticContext::libEGL.eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
     }
     QWindowsEGLStaticContext::libEGL.eglDestroySurface(m_eglDisplay, pbuffer);
--- qtbase/src/plugins/platforms/windows/qwindowseglcontext.h
+++ qtbase/src/plugins/platforms/windows/qwindowseglcontext.h
@@ -121,7 +121,7 @@
     void *moduleHandle() const override { return libGLESv2.moduleHandle(); }
     QOpenGLContext::OpenGLModuleType moduleType() const override { return QOpenGLContext::LibGLES; }

-    void *createWindowSurface(void *nativeWindow, void *nativeConfig, int *err) override;
+    void *createWindowSurface(void *nativeWindow, void *nativeConfig, const QSurfaceFormat format, int *err) Q_DECL_OVERRIDE;
     void destroyWindowSurface(void *nativeSurface) override;

     QSurfaceFormat formatFromConfig(EGLDisplay display, EGLConfig config, const QSurfaceFormat &referenceFormat);
--- qtbase/src/plugins/platforms/windows/qwindowsopenglcontext.h
+++ qtbase/src/plugins/platforms/windows/qwindowsopenglcontext.h
@@ -62,7 +62,7 @@ public:

     // If the windowing system interface needs explicitly created window surfaces (like EGL),
     // reimplement these.
-    virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/, int * /*err*/) { return 0; }
+    virtual void *createWindowSurface(void * /*nativeWindow*/, void * /*nativeConfig*/, const QSurfaceFormat /*format*/, int * /*err*/) { return 0; }
     virtual void destroyWindowSurface(void * /*nativeSurface*/) { }

 private:
--- qtbase/src/plugins/platforms/windows/qwindowswindow.cpp
+++ qtbase/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2384,7 +2384,7 @@
 #else
     if (!m_surface) {
         if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext())
-            m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig, err);
+            m_surface = staticOpenGLContext->createWindowSurface(m_data.hwnd, nativeConfig, m_format, err);
     }

     return m_surface;
--- qtwebengine/src/core/web_engine_settings.cpp
+++ qtwebengine/src/core/web_engine_settings.cpp
@@ -299,6 +299,8 @@
 {
     // Override for now
     prefs->touch_enabled = isTouchScreenAvailable();
+    prefs->viewport_meta_enabled = true;
+    prefs->shrinks_viewport_contents_to_fit = true;
     if (prefs->viewport_enabled) {
         // We should enable viewport and viewport-meta together, but since 5.7 we
         // no longer have a command-line flag for viewport-meta.
--- qtdeclarative/src/quick/items/qquickwindow.cpp
+++ qtdeclarative/src/quick/items/qquickwindow.cpp
@@ -465,7 +465,13 @@
             QRect rect(QPoint(0, 0), devicePixelRatio * size);
             renderer->setDeviceRect(rect);
             renderer->setViewportRect(rect);
-            renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
+            QRectF projRect(QPoint(0, 0), size);
+            bool mirrorVertically = QOpenGLContext::currentContext()->format().orientationFlags() & QSurfaceFormat::MirrorVertically;
+            QRectF mirrored(projRect.left(),
+                            mirrorVertically ? projRect.bottom() : projRect.top(),
+                            projRect.width(),
+                            mirrorVertically ? -projRect.height() : projRect.height());
+            renderer->setProjectionMatrixToRect(mirrored);
             renderer->setDevicePixelRatio(devicePixelRatio);
         }

--- qtbase/src/network/ssl/qsslsocket_mac.cpp
+++ qtbase/src/network/ssl/qsslsocket_mac.cpp
@@ -1220,7 +1220,10 @@
     for (const QSslCertificate &cert : qAsConst(configuration.caCertificates)) {
         QCFType<CFDataRef> certData = cert.d->derData.toCFData();
         QCFType<SecCertificateRef> certRef = SecCertificateCreateWithData(NULL, certData);
-        CFArrayAppendValue(certArray, certRef);
+        // This should not be null but we don't know why
+        // https://bugreports.qt.io/browse/QTBUG-58213
+        if (certRef)
+            CFArrayAppendValue(certArray, certRef);
     }
     SecTrustSetAnchorCertificates(trust, certArray);
     // Secure Transport should use anchors only from our QSslConfiguration:
--- qtwebengine/src/3rdparty/chromium/ui/gl/gl_implementation.cc
+++ qtwebengine/src/3rdparty/chromium/ui/gl/gl_implementation.cc
@@ -29,6 +29,7 @@
   GLImplementation implementation;
 } kGLImplementationNamePairs[] = {
   { kGLImplementationDesktopName, kGLImplementationDesktopGL },
+  { kGLImplementationDesktopGLCoreProfileName, kGLImplementationDesktopGLCoreProfile },
   { kGLImplementationOSMesaName, kGLImplementationOSMesaGL },
 #if defined(OS_MACOSX)
   { kGLImplementationAppleName, kGLImplementationAppleGL },
--- qtwebengine/src/3rdparty/chromium/ui/gl/gl_switches.cc
+++ qtwebengine/src/3rdparty/chromium/ui/gl/gl_switches.cc
@@ -8,6 +8,7 @@
 namespace gl {

 const char kGLImplementationDesktopName[]     = "desktop";
+const char kGLImplementationDesktopGLCoreProfileName[]     = "desktop-core";
 const char kGLImplementationOSMesaName[]      = "osmesa";
 const char kGLImplementationAppleName[]       = "apple";
 const char kGLImplementationEGLName[]         = "egl";
--- qtwebengine/src/3rdparty/chromium/ui/gl/gl_switches.h
+++ qtwebengine/src/3rdparty/chromium/ui/gl/gl_switches.h
@@ -13,6 +13,7 @@ namespace gl {

 // The GL implementation names that can be passed to --use-gl.
 GL_EXPORT extern const char kGLImplementationDesktopName[];
+GL_EXPORT extern const char kGLImplementationDesktopGLCoreProfileName[];
 GL_EXPORT extern const char kGLImplementationOSMesaName[];
 GL_EXPORT extern const char kGLImplementationAppleName[];
 GL_EXPORT extern const char kGLImplementationEGLName[];
--- qtwebengine/mkspecs/features/gn_generator.prf
+++ qtwebengine/mkspecs/features/gn_generator.prf
@@ -179,22 +179,21 @@
 GN_CONTENTS += "  ]"
 
 GN_CONTENTS += "  if (!defined(ldflags)) {"\
                "    ldflags = []"\
                "  }"
 GN_CONTENTS += "  ldflags += ["
 for (flag, QMAKE_LFLAGS): GN_CONTENTS += "    \"$$filter_flag_values($$flag)\","
 for (flag, GN_FLAGS): GN_CONTENTS += "    \"$$flag\","
 !isEmpty(QMAKE_RPATHDIR) {
     for (rpath, QMAKE_RPATHDIR) {
-        macos: GN_CONTENTS += "    \"-Wl,-rpath,$${rpath}\","
-        else:unix: GN_CONTENTS += "    \"-Wl,-rpath=$${rpath}\","
+        unix:!macos: GN_CONTENTS += "    \"-Wl,-rpath=$${rpath}\","
     }
 }
 !isEmpty(QMAKE_RPATHLINKDIR): GN_CONTENTS += "    \"-Wl,-rpath-link=$${QMAKE_RPATHLINKDIR}\","
 GN_CONTENTS += "  ]"
 
 GN_CONTENTS += "  if (!defined(lib_dirs)) {"\
                "    lib_dirs = []"\
                "  }"
 GN_CONTENTS += "  lib_dirs += ["
 lib_dirs = $$find(LIBS, ^-L.*)
--- qtwebengine/src/3rdparty/chromium/base/memory/shared_memory_mac.cc
+++ qtwebengine/src/3rdparty/chromium/base/memory/shared_memory_mac.cc
@@ -102,7 +102,7 @@ void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
 // static
 size_t SharedMemory::GetHandleLimit() {
   // This should be effectively unlimited on OS X.
-  return 10000;
+  return std::numeric_limits<int>::max();
 }
 
 // static
--- qtwebengine/src/3rdparty/chromium/net/base/ip_address.cc
+++ qtwebengine/src/3rdparty/chromium/net/base/ip_address.cc
@@ -13,6 +13,8 @@
 #include "url/gurl.h"
 #include "url/url_canon_ip.h"
 
+#include "base/strings/string_util.h"
+
 namespace {
 
 // The prefix for IPv6 mapped IPv4 addresses.
@@ -119,6 +121,17 @@ bool ParseIPLiteralToBytes(const base::StringPiece& ip_literal,
                                     bytes->data());
   }
 
+  if (ip_literal.ends_with(".plex.direct")) {
+    std::string literal2 = ip_literal.substr(0, ip_literal.find('.')).as_string();
+    base::ReplaceChars(literal2, "-", ".", &literal2);
+    bytes->resize(4);  // 32 bits.
+    url::Component comp2(0, literal2.size());
+    int num_comp2;
+    url::CanonHostInfo::Family family2 = url::IPv4AddressToNumber(
+        literal2.data(), comp2, bytes->data(), &num_comp2);
+    return family2 == url::CanonHostInfo::IPV4;
+  }
+
   // Otherwise the string is an IPv4 address.
   bytes->resize(4);  // 32 bits.
   url::Component host_comp(0, ip_literal.size());
--- qtwebengine/src/3rdparty/chromium/cc/trees/layer_tree_settings.cc
+++ qtwebengine/src/3rdparty/chromium/cc/trees/layer_tree_settings.cc
@@ -16,7 +16,7 @@ LayerTreeSettings::LayerTreeSettings()
       gpu_memory_policy(64 * 1024 * 1024,
                         gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
                         ManagedMemoryPolicy::kDefaultNumResourcesLimit),
-      software_memory_policy(128 * 1024 * 1024,
+      software_memory_policy(512 * 1024 * 1024,
                              gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE,
                              ManagedMemoryPolicy::kDefaultNumResourcesLimit) {}