tryphotino / photino.Blazor

https://tryphotino.io
Apache License 2.0
349 stars 63 forks source link

Photino is using libwebkit2gtk-4.0-37 but building a flatpak that supports .NET 8 requires libwebkit2gtk-4.1 #134

Open Jinjinov opened 2 months ago

Jinjinov commented 2 months ago

I wanted to build a flatpak, but currently Photino is using libwebkit2gtk-4.0-37 In flatpak yaml, instead of

runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk

you have to use

runtime: org.gnome.Platform
runtime-version: '46'
sdk: org.gnome.Sdk

Because: https://docs.flatpak.org/en/latest/available-runtimes.html The GNOME runtime is appropriate for any application that uses the GNOME platform. It is based on the Freedesktop runtime and adds the GNOME platform, including WebKitGTK

But Gnome 46 includes libwebkit2gtk-4.1

I tried using Gnome 41 that includes libwebkit2gtk-4.0 but Gnome 41 can not use .NET 8:

sdk-extensions:
  - org.freedesktop.Sdk.Extension.dotnet8

It can only support org.freedesktop.Sdk.Extension.dotnet5 and org.freedesktop.Sdk.Extension.dotnet6

This is my flatpak yaml:

id: net.openhabittracker.app
runtime: org.gnome.Platform
runtime-version: '46'
sdk: org.gnome.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.dotnet8
build-options:
  prepend-path: "/usr/lib/sdk/dotnet8/bin"
  append-ld-library-path: "/usr/lib/sdk/dotnet8/lib"
  prepend-pkg-config-path: "/usr/lib/sdk/dotnet8/lib/pkgconfig"

command: OpenHT

finish-args:
  - --device=dri
  - --socket=x11
  - --share=ipc
  - --env=DOTNET_ROOT=/app/lib/dotnet

modules:
  - name: dotnet
    buildsystem: simple
    build-commands:
    - /usr/lib/sdk/dotnet8/bin/install.sh

  - name: OpenHabitTracker
    buildsystem: simple
    sources:
      - type: git
        url: https://github.com/Jinjinov/OpenHabitTracker.git
        branch: main
      - ./nuget-sources.json
    build-commands:
      - dotnet publish OpenHabitTracker.Blazor.Photino/OpenHabitTracker.Blazor.Photino.csproj -c Release -r linux-x64 -p:PublishSingleFile=true -p:SelfContained=true --source ./nuget-sources
      - mkdir -p ${FLATPAK_DEST}/bin
      - cp -r OpenHabitTracker.Blazor.Photino/bin/Release/net8.0/linux-x64/publish/* ${FLATPAK_DEST}/bin
Jinjinov commented 2 months ago

I tried building webkit2gtk-4.0 from source, but the build always fails on my PC with 16 GB of RAM and 16 GB of SWAP (increased from 2 GB).

I can't use old Gnome which includes webkit2gtk-4.0 because it doesn't support .NET 8

I can't use new Gnome because it only includes webkit2gtk-4.1 but Photino needs webkit2gtk-4.0

I can't build webkit2gtk-4.0 from source, because the build always fails...

I don't know what else I can try...

id: net.openhabittracker.app
#runtime: org.freedesktop.Platform
#runtime-version: '23.08'
#sdk: org.freedesktop.Sdk
runtime: org.gnome.Platform
runtime-version: '46'
sdk: org.gnome.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.dotnet8
build-options:
  prepend-path: "/usr/lib/sdk/dotnet8/bin"
  append-ld-library-path: "/usr/lib/sdk/dotnet8/lib"
  prepend-pkg-config-path: "/usr/lib/sdk/dotnet8/lib/pkgconfig"

command: OpenHT

finish-args:
  - --device=dri
  # TODO: Replace this with wayland and fallback-x11 once Wayland support
  #       becomes available:
  #       https://github.com/AvaloniaUI/Avalonia/pull/8003
  - --socket=x11
  - --share=ipc
  - --env=DOTNET_ROOT=/app/lib/dotnet

modules:
  - name: webkit2gtk-4.0
    sources:
      - type: archive
        url: https://webkitgtk.org/releases/webkitgtk-2.44.4.tar.xz
        sha256: 2ce4ec1b78413035037aba8326b31ed72696626b7bea7bace5e46ac0d8cbe796
        x-checker-data:
          type: html
          url: https://webkitgtk.org/releases/
          version-pattern: LATEST-STABLE-(\d[\.\d]+\d)
          url-template: https://webkitgtk.org/releases/webkitgtk-$version.tar.xz
    buildsystem: cmake-ninja
    config-opts:
      - -DPORT=GTK
      - -DCMAKE_BUILD_TYPE=RelWithDebInfo
      - -DENABLE_DOCUMENTATION=OFF
      - -DENABLE_MINIBROWSER=OFF
      - -DENABLE_WEBDRIVER=OFF
      - -DENABLE_GAMEPAD=OFF
      - -DUSE_LIBBACKTRACE=OFF
      - -DUSE_GTK4=OFF
      - -DUSE_SOUP2=ON
      - -DENABLE_BUBBLEWRAP_SANDBOX=OFF
    modules:
      - name: libsoup-2.4
        buildsystem: meson
        config-opts:
        - "-Dtests=false"
        sources:
        - type: archive
          url: https://download.gnome.org/sources/libsoup/2.74/libsoup-2.74.3.tar.xz
          sha256: e4b77c41cfc4c8c5a035fcdc320c7bc6cfb75ef7c5a034153df1413fa1d92f13

      - name: unifdef
        no-autogen: true
        make-install-args:
          - prefix=${FLATPAK_DEST}
        sources:
          - type: archive
            url: https://dotat.at/prog/unifdef/unifdef-2.12.tar.xz
            sha256: 43ce0f02ecdcdc723b2475575563ddb192e988c886d368260bc0a63aee3ac400
        cleanup:
          - '*'

  - name: dotnet
    buildsystem: simple
    build-commands:
    - /usr/lib/sdk/dotnet8/bin/install.sh

  - name: OpenHabitTracker
    buildsystem: simple
    sources:
      - type: git
        url: https://github.com/Jinjinov/OpenHabitTracker.git
        branch: main
      - ./nuget-sources.json
    build-commands:
      - dotnet publish OpenHabitTracker.Blazor.Photino/OpenHabitTracker.Blazor.Photino.csproj -c Release -r linux-x64 -p:PublishSingleFile=true -p:SelfContained=true --source ./nuget-sources
      - mkdir -p ${FLATPAK_DEST}/bin
      - cp -r OpenHabitTracker.Blazor.Photino/bin/Release/net8.0/linux-x64/publish/* ${FLATPAK_DEST}/bin
philippjbauer commented 1 month ago

@Jinjinov can you adapt you FP configuration to not reference the dotnet SDK? If you publish your Photino app as a single file executable it will include the runtime for dotnet.

Here's the guide I prepared for packaging in Linux and it has worked for me so far.

https://github.com/tryphotino/photino.Samples/tree/master/Photino.PublishPhotino/PublishPhotino#universal-packaging-with-flatpak

Jinjinov commented 1 month ago

What is the reason for using the deprecated libwebkit2gtk-4.0-37 ?

Is it too hard to update to libwebkit2gtk-4.1 ?

Are the any breaking changes?

Can I help somehow?

MikeYeager commented 1 month ago

@Jinjinov There are some breaking changes between 4.0 and 4.1 and we have to compile with one or the other. We want to avoid making a separate NuGet package just for Linux if possible. Currently, 4.0 is more widely supported and, if we switch to 4.1, all of the existing apps using 4.0 will break (we actually did one release with 4.1 and it didn't go well, so we reverted). @philippjbauer is going to take a stab at figuring out path forward. In the interim, have you tried version 45? We think in our testing it worked with both .NET 8 and 4.0.

ivanjx commented 1 month ago

running the hello world sample also fails on ubuntu 24.04 LTS. i think it is very important to support 4.1 soon.

flyingpie commented 5 days ago

Same issue, can't get Photino to run in Flatpak, after following the Hello World sample.

These should be the available libwebkit2gtk versions, per Gnome version:

41  libwebkit2gtk-4.0.so.37.56.10

42  libwebkit2gtk-4.0.so.37.57.8

43  libwebkit2gtk-4.1.so.0.8.5
43  libwebkit2gtk-5.0.so.0.0.0

44  libwebkit2gtk-4.1.so.0.12.8

45  libwebkit2gtk-4.1.so.0.13.8

46  libwebkit2gtk-4.1.so.0.16.5

So the most recent version still providing 4.0 is 42, but that results in the following error:

/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /app/bin/Photino.Native
.so)

And the Gnome 42 runtime comes with:

sh-5.1$ strings /lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_3.4.29
GLIBCXX_DEBUG_MESSAGE_LENGTH

Not sure if building Photino.Native from within the Flatpak would fix that, but maybe it's solving the wrong problem given the used Gnome versions.

flyingpie commented 3 days ago

@Jinjinov There are some breaking changes between 4.0 and 4.1 and we have to compile with one or the other. We want to avoid making a separate NuGet package just for Linux if possible. Currently, 4.0 is more widely supported and, if we switch to 4.1, all of the existing apps using 4.0 will break (we actually did one release with 4.1 and it didn't go well, so we reverted). @philippjbauer is going to take a stab at figuring out path forward. In the interim, have you tried version 45? We think in our testing it worked with both .NET 8 and 4.0.

Could you elaborate, or point me to an issue or something where the problems are detailed?