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.19k stars 363 forks source link

libcef.so can't be loaded in Ubuntu 23.10 for RaspberryPi #457

Open salvadordf opened 1 year ago

salvadordf commented 1 year ago

There's an initialization issue in Ubuntu 23.10 for RaspberryPi (ARM CPU).

libcef.so can't be loaded and GlobalCEFApp.StartMainProcess fails with a blank background.

Perhaps chromium has changed the default TLS model.

Workaround : Open a terminal window and execute the following command : export LD_PRELOAD=<FULL-PATH-TO-libcef.so> Then run the GTK3 demos.

Original forum thread : https://forum.lazarus.freepascal.org/index.php/topic,62987.0.html

CEF forum thread : https://magpcss.org/ceforum/viewtopic.php?f=6&t=19622#p54408

CEF issue : https://github.com/chromiumembedded/cef/issues/3616

Chromium issue : https://bugs.chromium.org/p/chromium/issues/detail?id=1508362

afuriza commented 1 year ago

In X86 Linux it works fine with GTK3, I am using the 109.1.11 version but I also have the same problem, it doesn't show any error but a blank screen in ARM or AArch64. image

Also, I can't run simplecef in ARM or AArch64, it doesn't give any output in console. No matter which version, 112 or 109. image

Is not this the bug of the CEF builds from Spotify CDN?

rcla commented 1 year ago

@afuriza

I use the version that @salvadordf recommended "CEF 106.1.1 which includes Chromium 106.0.5249.119"

Release 106.0.5249.119

And I download the Sample application and run "cefsimple" and it works without problems inside Ubuntu Desktop arm64 and Fedora 37 aarch64 Download Cefsimple arm64

cefsimple running on Fedora aarch64: cefsimple

Please note that LCL widget type "gtk3" is in "alpha" stage.

afuriza commented 1 year ago

@rcla Thank you, that helps me a lot. I'll try the version 106.

afuriza commented 1 year ago

I just tested the "cefsimple" in Ubuntu AArch64, it works but blank window on any demo from CEF4Delphi without any error or any log produced.

jwj76 commented 1 year ago

I also encountered the same problem on Linuxarm64. Using getconf PAGESIZE, it is 65536. Some people say that the PAGESIZE of libcef.so is 4096, and all errors occur. Is it possible? How to solve it?

jwj76 commented 1 year ago

Using ldd libcef.so to display the results is not a dynamic executable.

Use/lib64/ld Linux arrch64. so. 1-- list libcef. so

Elf load command alignment not page aligned

Readelf - l libcef.so returns a load segment size of 0x1000 (4K)

Getconf PAGESIZE, which is 65536 (64K)

Use file libcef.so to check if it is normal.

The CEF version used is 87.0.4280.141.

salvadordf commented 11 months ago

I tried to use cmem but LoadLibrary also returns 0. I still need to learn a lot about programming in Linux to debug this issue.

jwj76 commented 8 months ago

For CEF4_87. 0.4280.141 LinuxAarch64 cannot be getconf PAGESIZE system of 64 k. Since Chromium will not be compiled, the following attempts can only be made: The platform is: Ubuntu Server 20.04 arm64 pagesize=4k CEF4_87.0.4280.141LinuxArmhf pagesize=64K

  1. Use dpkg --add-architecture armhf Added Armhf runtime support.
  2. Use apt to increase the dependency packages required by CEF. Note that apt install xxxx:armhf is used to add the package. Also use ln -s /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 /lib/ld-linux-armhf.so3 to install the loader.
  3. After all the dependencies are added, CEF can run normally and display web pages. Question: Perform the following operations in the Kylin arm64 pagesize=64K environment.
  4. Copy all files of /lib/arm-linux-gnueabihf in Ubuntu to the corresponding directory of Kylin.
  5. Since the pagesize of libLLVM-15.so.1 =4k, find the libLLVM15 for armhf dependency package with pagesize=64K. And download libncursesw.so.6 dependency. Copy them all to /lib/arm-linux-gnueabihf.
  6. ln -s /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 /lib/ld-linux-armhf.so3 In this case, the CEF test program can be run, but the error "fatal:page_allocator_internals_posix.h(169) check failed" occurs twice. And the interface is blank and does not load the page. Display thread discovery with ps Ubuntu Server 20.04 arm64 cef has 6 threads The cef in Kylin arm64 has only 5 threads.

View pagesize with readelf -l xxx.so. After LOAD, 0x1000 is 4K, and 0x10000 is 64K.

salvadordf commented 7 months ago

I'm getting the same error with a beta version of CEF4Delphi that uses CEF 119.

I replaced the LoadLibrary call with this : FLibHandle := TLibHandle(dlopen(PAnsiChar(UTF8Encode(LibCefPath + #0)), RTLD_LAZY or RTLD_LOCAL));

dlopen is returning a zero and a call to dlerror gives this message : cannot allocate memory in static TLS block.

This message is the same in x86 and Raspberry when I try to load libcef.so

salvadordf commented 7 months ago

Workaround Open a terminal window and execute the following command : export LD_PRELOAD=<FULL-PATH-TO-libcef.so> Then run the GTK3 demos.

CEF 118 and older versions worked correctly in Intel x64.

jwj76 commented 7 months ago

When the cef program of armhf (32) is executed in arm64, after the fcitx input method is enabled, two characters will appear when the keyboard enters one character in the English input state. You cannot enter any characters in the Chinese state, including English. After fcitx is disabled, input characters are normal. Please tell me how to set up to use fcitx to input Chinese.

salvadordf commented 7 months ago

There are several CEF issues related to the IME in Linux. Please, use our forum for questions unrelated to this libcef.so issue.

jwj76 commented 7 months ago

The armhf version of CEF running under arm64 cannot be used in Chinese. There is no associated SO library file, armhf default input method is xim. Only add fcitx fcitx5 ibus and other input methods in the armhf library file, and set up can be used.

jwj76 commented 7 months ago

Now you can use cef+flash+ Chinese input in Arm64. Thank you all! The method is to install armhf support under arm64 and choose linux arm when developing and compiling. And install CEF required Armhf required library files. The principle is the same as running win32 programs under win64. windows64 already includes 32 - and 64-bit dynamic libraries. There is no arm32 library in arm64, so you need to install it manually. There's still a slight problem. getconf PAGESIZE 4096 works in arm64. There's no problem. But in getconf PAGESIZE 65536, it may not work. The fatal page_allocator_internals_posix.h(169) check failed error message is displayed. CEF is also loading, that is, showing the page as blank.

salvadordf commented 7 months ago

The CEF 119.4.7 update fixes the "cannot allocate memory in static TLS block" issue for x64 CPUs but Ubuntu 23.10 for Raspberry Pi is still affected.

salvadordf commented 3 weeks ago

CEF 126.1.14 has this issue in Linux Mint again.