ultralight-ux / Ultralight

Lightweight, high-performance HTML renderer for game and app developers.
https://ultralig.ht
4.66k stars 194 forks source link

How to run the samples on M1 macOS on 'arm64' architecture? Issues with resources? #509

Open Dima-369 opened 1 month ago

Dima-369 commented 1 month ago

Hi, I want to test out Ultralight on my M1 macOS. I tried both 1.4.x and v1.4.0b, and it successfully compiles, but launching any .app instantly crashes with this error:

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: @rpath/libUltralightCore.dylib

I was able to fix it by manually modifying the Info.plist for the apps like in ultralight-sdk-latest-mac-arm64/build/samples/Sample 8 - Web Browser/Sample8.app/Contents/Info.plist by adding:

<key>DYLD_LIBRARY_PATH</key>
<string>/Users/dima/Downloads/ultralight-sdk-latest-mac-arm64/bin/</string>

Now, it does not crash instantly, but reports this error:

Failed to load ICU data (icudt67l.dat) from the FileSystem interface. Make sure that you've defined a FileSystem and the file can be found in the correct path. Aborting.

and this:

Could not load resource: resources/icudt67l.dat, FileSystem::FileExists() returned false.

Does anyone know how to fix this? Thanks!

robotogre commented 3 weeks ago

I'm having the same issue.

OndrejKarlik commented 3 weeks ago

The issue happens on all OS, there is probably a bug in cmake/build scripts that causes the resources not be copied where they need to be, if you copy them manually it works

robotogre commented 3 weeks ago

@OndrejKarlik

resources not be copied where they need to be, if you copy them manually it works

Where should they be copied to exactly? I've copied the 'resources' folder from ultralight-sdk-latest-mac-arm64/build to ultralight-sdk-latest-mac-arm64/build/samples/Sample 1 - Render to PNG

Screenshot 2024-08-25 at 9 40 08 PM
robotogre@MBP:~/Downloads/ultralight-sdk-latest-mac-arm64/build/samples/Sample 1 - Render to PNG $ ./Sample1
Initializing Ultralight v1.4.0 (WebKit 615.1.18.100.1) with the following configuration
    cache_path:
    resource_path_prefix: resources/
    face_winding: CounterClockwise
    font_hinting: Normal
    font_gamma: 1.8
    force_repaint: disabled
    animation_timer_delay: 16.7 ms
    scroll_timer_delay: 16.7 ms
    recycle_delay: 4.0 s
    memory_cache_size: 64.00 MB
    page_cache_size: 0 pages
    override_ram_size: disabled
    min_large_heap_size: 32.00 MB
    min_small_heap_size: 1.00 MB
    num_renderer_threads: 0
    max_update_time: 5.0 ms
    bitmap_alignment: 16

Could not load resource: resources/icudt67l.dat, FileSystem::FileExists() returned false.

Failed to load ICU data (icudt67l.dat) from the FileSystem interface. Make sure that you've defined a FileSystem and the file can be found in the correct path. Aborting.
OndrejKarlik commented 3 weeks ago

Ultralight filesystem works from ./assets/ by default, so that would be ./assets/resources/icudt67l.dat (relative to CWD of the process). This works on my machine. But looking at the code it might be different on macOS based on its app conventions. See ultralight::Settings::file_system_path and ultralight::Config::resource_path_prefix

robotogre commented 3 weeks ago

@OndrejKarlik

Ultralight filesystem works from ./assets/ by default

It works!!!!!

Thank you so much for taking the time to help.

ultralight-sdk-latest-mac-arm64/build/samples/Sample 1 - Render to PNG/assets/resources

ultralight-sdk-latest-mac-arm64/build/samples/Sample 7 - OpenGL Integration/Sample7.app/Contents/MacOS/assets/resources