salvadordf / CEF4Delphi

CEF4Delphi is an open source project to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows, Linux and MacOS.
https://www.briskbard.com/forum/
Other
1.22k stars 373 forks source link

MacOS : Access violation when the browser tries to show a modal window or the context menu. #368

Closed salvadordf closed 3 years ago

salvadordf commented 3 years ago

The Firemonkey and Lazarus demos in MacOS using an external message pump crash when the application shows a modal window or the context menu.

The AV happens when the work scheduler class calls GlobalCEFApp.DoMessageLoopWork from a background thread while the browser is behind a modal window.

salvadordf commented 3 years ago

Firemonkey doesn't allow to subclass NSApplication in MacOS and we can't control when sendEvent is called at all times.

Chromium requires that we return TRUE from CrAppProtocol.isHandlingSendEvent when sendEvent is in the call stack but the current CrAppPrortocol implementation misses some sendEvent calls and that is cause of the crashes.

As a workaround, the demos replace the context menu and the JavaScript dialogs with custom FMX menus and dialogs.

At this moment, we can only use this workaround and add more replacements if necessary.