Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ExternalPumpBrowser Lazarus demo crashes after navigation in macOS 15.1.1 on an M4 CPU. #538

Open
sxmxta opened this issue Dec 1, 2024 · 7 comments

Comments

@sxmxta
Copy link

sxmxta commented Dec 1, 2024

Hello,

When I was doing the encapsulation of the energy framework on MacOS M4 and conducting tests, I found that in the TCefApplicationCore.LoadCEFlibrary function, the loading of the CEF library failed during the startup initialization. The value returned by FLibHandle := LoadLibrary(LibCefPath); is 0.

System environment:
MacOS ARM64
Version: 15.1.1

Sample program: ExternalPumpBrowser

No errors were found on MacOS Intel x86, M1, and lower-version M2 systems.


In addition, there are other issues.

I encapsulated CEF4Delphi as a dynamic link library. Since the return value of loading the lib library is 0, I pre-loaded the CEF Lib library in the calling language of the library and then passed the handle to FLibHandle through the API.

In this way, the APIs related to initializing the CEF lib can be initialized normally. However, there are some problems. After running, when opening certain websites or right-clicking on the program, it will crash.

@salvadordf
Copy link
Owner

I don't have a mac computer and I can't test CEF4Delphi. Read about the notarization requirements in newer macOS versions.

If you initialize CEF inside a DLL then the browsers must be created in the DLL's code too. See the DLLBrowser demo.

@sxmxta
Copy link
Author

sxmxta commented Dec 2, 2024

hello

Maybe there's something wrong with the way I said it.

Let me rephrase the problem.
Let's start with the simplest.

CEF 130.1.16
System: MacOS 15.1
demo: ExternalPumpBrowser
IDE: Lazarus 3.6

Problem: When the program is started, the Chromium Embedded Framework returns 0

The ExternalPumpBrowser example works fine on MacOS 12

@salvadordf
Copy link
Owner

I just received a confirmation that CEF4Delphi works fine in macOS 15.1 for x86.

The """closest""" (notice the quotes) thing I can personally test is a RaspberryPi 5 with an arm64 processor and it also works fine.

I can only suggest that you enable the debug log and also read the GlobalCEFApp.LastErrorMessage value. Post the log and the GlobalCEFApp.LastErrorMessage value here.

Try running the official CEF sample application on MacOS 15.1 in a M4 processor.
https://cef-builds.spotifycdn.com/cef_binary_131.2.7%2Bg9a14dc9%2Bchromium-131.0.6778.86_macosarm64_client.tar.bz2

@salvadordf salvadordf reopened this Dec 3, 2024
@sxmxta
Copy link
Author

sxmxta commented Dec 4, 2024

Okay, thank you,

The cefclient example works properly.

CEF4Delphi It does not work properly in a lazarus environment. Which is the problem I described above

@sxmxta
Copy link
Author

sxmxta commented Dec 4, 2024

In the environment of macOS 15.1.1 and Lazarus 3.6, I've discovered several problems:

  1. When loading the CEF Lib, it returns 0.
  2. The timing for initializing the objective-c NSApp in the AddCrDelegate function is incorrect. It is required to execute "TCrCocoaApplication.sharedApplication;" in advance.
  3. After the page is displayed, the program crashes when switching the input method. Moreover, the program crashes when loading some pages.

Explanation:
Problem 2:

app.SetMultiThreadedMessageLoop(false)
app.SetExternalMessagePump(false)

Resolved:

procedure AddCrDelegate;
var
  delegate: id;
begin
  // CEF要求在创建NSApp之前,必须先实例化 TCrCocoaApplication 
  // 否则CEF获取不到 isHandlingSendEvent
  TCrCocoaApplication.sharedApplication;
  delegate := TChromeAppDelegateIntercept.alloc.initWithDelegate(NSApp.delegate);
  NSApp.setDelegate(delegate);
end;

Problem 3:

app.SetExternalMessagePump(true)
app.SetMultiThreadedMessageLoop(false)

salvadordf added a commit that referenced this issue Dec 4, 2024
@salvadordf
Copy link
Owner

salvadordf commented Dec 4, 2024

I just updated CEF4Delphi with a possible fix for this issue.

Please, download CEF4Delphi again and test demos\Lazarus_Mac\ExternalPumpBrowser in macOS 15.1 with the M4 CPU.

@sxmxta
Copy link
Author

sxmxta commented Dec 5, 2024

1733387868871
WX20241205-163955
WX20241205-163828


It still crashes, as shown in the figure above.

Some websites crash after loading.

Note: google is not the only site to crash, any other site can crash.
But there are also simple websites that don't crash

@salvadordf salvadordf changed the title MacOS arm64 CEF 130.1.16 loads the CEF library. The result of LoadLibrary is 0. ExternalPumpBrowser Lazarus demo crashes after navigation in macOS 15.1.1 on an M4 CPU. Dec 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants