Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Flatpak Support #67

Closed
tseli0s opened this issue Apr 2, 2023 · 11 comments · Fixed by #70
Closed

Flatpak Support #67

tseli0s opened this issue Apr 2, 2023 · 11 comments · Fixed by #70

Comments

@tseli0s
Copy link

tseli0s commented Apr 2, 2023

A very large amount of GNU/Linux applications use the Flatpak packaging format, which, apart from other features, runs the packaged application inside a container. This causes a problem with this crate however, where the browser cannot be located.

Even if specifying full access to the filesystem in the build manifest, some directories are by definition inaccessible to the application, as well as any other Flatpak application available.

There are three solutions to this:

  • Require the user to have a browser natively installed.
  • Require the developer to ship their own browser (Afaik this is what Electron does with Flathub, however I am not sure so feel free to correct me)
  • Or, just make the developer display their webpage in-app as a fallback, which probably requires another crate entirely, and probably one of the two options as well.
@amodm
Copy link
Owner

amodm commented Apr 2, 2023

@tseli0s, any reason why you think this should be handled inside this crate, instead of the user application handling the error code bubbled up by this crate? The latter approach is the norm in the Rust ecosystem.

Can you also point me how some of the other applications handle such scenarios? Electron isn't the best example here because it packages a browser by definition, while the goal of this crate isn't to bundle a browser, but to open an existing one.

Thanks.

@tseli0s
Copy link
Author

tseli0s commented Apr 3, 2023

any reason why you think this should be handled inside this crate, instead of the user application handling the error code bubbled up by this crate? The latter approach is the norm in the Rust ecosystem.

Because "handling the error" is not enough. What if the application requires for example signing in? That requires a web browser on all distros. And yes, the developer may not intend to ship it as a Flatpak in that case, but it's often the community packaging the software and flathub takes a long time to respond to takedown requests. In addition, the crate guarantees to open the webpage (According to the documentation), if there's a browser available.

Can you also point me how some of the other applications handle such scenarios? Electron isn't the best example here because it packages a browser by definition, while the goal of this crate isn't to bundle a browser, but to open an existing one.

Most of them usually use xdg-open, and the default browser (If set) will always open. If you give me some time I can show you actual projects and their source code to handle that, because nothing comes off the top of my head. Although data sharing is limited or non existent, it is guaranteed to open a page. Issues that may come up are when opening files instead of webpages (May launch the file manager), or when xdg-open is not installed (Which is extremely rare).

@amodm
Copy link
Owner

amodm commented Apr 3, 2023

Because "handling the error" is not enough. What if the application requires for example signing in?

Ah, ok. I misread your original comment as saying that the browser doesn't exist.

Most of them usually use xdg-open, and the default browser (If set) will always open

What I'm gathering is that the browser is available to flatpak apps, but needs special way of handling the flatpak environment perhaps.

If you give me some time I can show you actual projects and their source code to handle that

Yes, this will be very helpful, thanks. In the meantime, I'll read up on Flatpak as I get some time.

@tseli0s
Copy link
Author

tseli0s commented Apr 4, 2023

What I'm gathering is that the browser is available to flatpak apps, but needs special way of handling the flatpak environment perhaps

Kind of, also it's distro-specific sometimes so a few distros may just refuse to make it easier.

@amodm
Copy link
Owner

amodm commented Apr 9, 2023

I tried deploying the generated test binary under flatpak today, and it seems to open the browser just fine. Can you share a sample repo where this is not working?

The manifest I used was the following (test binary would be random in name):

app-id: in.rootnet.webbrowser
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
command: /app/bin/webb
modules:
  - name: webbrowser
    buildsystem: simple
    build-commands:
      - install -D target/debug/deps/test_unix-06e5c2910415d159 /app/bin/webb
    sources:
      - type: dir
        path: .

@tseli0s
Copy link
Author

tseli0s commented Apr 11, 2023

For me, it doesn't work with my own application and a test one I deployed later to investigate. This is the error I get:

Unable to open webpage 'https://github.com/': No valid browsers detected. You can specify one in BROWSERS environment variable

What permissions do you have? For me, this is my finish-args:

        "--share=ipc",
        "--socket=x11",
        "--socket=wayland",
        "--device=all",
        "--filesystem=host"

ipc is for X11 and Wayland to work, device is just for game controllers and the most important part is --filesystem=host, which basically gives access to the host system.
But, as the documentation says, some directories (Which is probably where a browser would be placed) are blacklisted by default and nothing can be done about it.
If it helps, I run elementaryOS 7.0.

@amodm
Copy link
Owner

amodm commented Apr 11, 2023

Noted. I'm doing this on Ubuntu, but let me see if I can install Elementary, or play around sufficiently with Flatpak to replicate this issue.

@amodm
Copy link
Owner

amodm commented Apr 11, 2023

@tseli0s, I'm able to replicate the issue on Elementary OS. I've pushed a fix in the flatpak branch. Can you see if that branch solves the issue for you? It seems to work in my installation.

@tseli0s
Copy link
Author

tseli0s commented Apr 12, 2023

Yep, works flawlessly. Should I report this behavior upstream?

@amodm
Copy link
Owner

amodm commented Apr 12, 2023

Great, thanks for checking & for the report. I'll make a release of this soon.

Should I report this behavior upstream?

No, the issue isn't with Flatpak, so you don't have to report this upstream.

@amodm
Copy link
Owner

amodm commented Apr 12, 2023

FYI, this is now out as v0.8.9. Thanks for the report & helping expand coverage.

yonip23 added a commit to codota/webbrowser-rs that referenced this issue Jul 11, 2023
* Added initial support for Haiku

* add android support

* Fix gitignore

* Release 0.5.3. Fixes amodm#23

* Fix README

* Release 0.5.4 with updated README

* featuer/add support for wasm

* change approach

* fix issues

* Try out GitHub Actions

* Update build status badge

* Fix build badge logo

* Fix fmt

* Remove ubuntu from test env

* Pull windows code out separately

* Fix fmt error

* Fix windows build

* Modify CI workflow

* Separate android

* CI for Android

* Move windows tests into windows module

* Separate macos

* Move unix systems out

* Remove travis ci

* Fail build only on stable rust

* Include WASM build step

* Fix compilation failure on unix

* Fix android build failure

* Ignore IE test case for windows for now

* Have separate job definitions for unix, windows and macos

* Release 0.5.5, with support for WASM

* Better name for CI steps

* Refactor tests as integration tests

* Fix tests for windows

* Fix macos test leakage into other platforms

* Do graceful shutdown of test server

* Separate workflows for different platforms

* Move build status to next line

* Use JNI to start the activity

* Allow a range of ndk-glue versions

* test for android

* remove unnecessary import

* fix cargo fmt checks

* Prevent caching of CI badge

* set UTF-8 encoding when running tests on macos

* set TERM to xterm when running tests on macos

* disable utf-8 url test for macos

* Include note for macos tests in platform support documentation

* ignore platform specific branches for CI builds

* use android emulator for android tests

* include i686-linux-android target for android builds

* use actions-rs/install for cargo-apk

* delete unrelevant open command for unix

* use specific version of cargo-apk as we are using tool-cache

* Use actions-rs/cache instead of cargo-apk-cache

* fix caching step

* [skip ci] better way to represent platform support

* [skip ci] more README fixes

* Breaking change: modify publicly exposed signature to bring consistency.
Fixes amodm#42

* restrict rust stable/beta/nightly build combo to only Linux for now. Windows still retains beta because of native lib bindings

* Fix wasm build

* put in tests for wasm

* fix wasm actions yaml

* fix wasm actions yaml: specify firefox version as a string

* allow wasm tests to be run on linux

* fix headless browser script for wasm tests

* fix linter error for wasm test

* [skip ci] update status of platforms

* [skip ci] update docs link

* Bring consistent behaviour on Unix. Non-terminal browsers are guaranteed to not block the thread

* richer set of commands for unix

* fix handling of unicode characters in URL

* handle haiku explicitly under unix

* run tests for linux using curl

* Document consistent behaviour, and provide way of overriding suppression of output

* conditional compilation for debugging macos tests

* fix lint for macos

* [skip ci] macos tests for utf-8 URLs is now addressed, so no need for a mention

* update dependency versions

* github actions for release process

* Release notes for 0.6.0

* [skip ci] specify token for crates publishing in a better way

* [skip ci] Fix release workflow name

* [skip ci] git ignore code-workspace files

* Move to latest actix version for testing

* fix tests

* fix wasm test

* add target_hint to BrowserOptions

* use builder pattern, fix default target & display impl

* fix linter error

* Clarify role of hints in BrowserOptions

* Add to CHANGELOG for v0.7.0

* Move version to 0.7.0

* Introduce BrowserOptions::is_available() to fix amodm#46

* clearer doc for BrowserOptions [skip ci]

* release v0.7.1 [skip ci]

* Rename default branch to main

* Fix anchor links in CHANGELOG [skip ci]

* Open url on iOS

* Edit compile error

* Remove unnecessary cfgs

* Fix typos & missing imports

* Include iOS tests (close amodm#49)

* fix test status badge in doc

* fix lint warning on nightly toolchain

* make sure multiple windows build jobs do not conflict with each other

* Run all matrix sequentially for Linux

* bump up version to 0.8.0 and update dependency versions

* update changelog for 0.8.0

* fix android tests

* Release 0.8.0

* android: Use ndk-context instead of ndk-glue to access JVM

This makes webbrowser-rs more compatible with different Android
application frameworks by not imposing that applications must use
ndk-glue.

This also bumps the `jni` dependency to 0.20 and uses the
`JObject::from_raw` API.

Fixes: amodm#51

* temporarily specify clippy msrv. remove this when releasing v1.0.0 and move to rust-version

* satisfy nightly clippy warnings

* Bump up crate version to 0.8.1

* update changelog for 0.8.1

* android: address failure on termux in absence of vm context

* check for termux before invoking android context

* Release v0.8.2

* fix license display on github [skip ci]

* Implement wsl compatibility

* force opening of browser on windows, instead of local file association

* fix lint for windows code

* on unix, detect default xdg browser and use that to bypass local file associations

* allow for selective builds during pushes

* tests: ensure wasm pkg dir #build-wasm

* tests: enable trace logging on all platforms

* fix wasm build #build-wasm #build-windows

* do not do the compilers job

* test for xdg open [skip-ci]

* tests: increase wait timeout on windows as github windows runner seems a bit slow #build-windows

* change internal signature to better handle url and local paths separately

* refactor TargetType

* move macos implementation to use CoreFoundation instead of open #build-macos

* define consistent behaviour to include opening web browser even for local files

* tests for local html file opening in browser

* fix wasm build #build-wasm

* fix wasm build (again) #build-wasm

* create the right url targettype for wasm #build-wasm

* fix linux and windows builds #build-linux #build-windows

* fix linux build #build-linux

* attempt #3 to fix linux build #build-linux

* update github action versions

* allow for optional hardened feature as a strict security precaution

* linux: move away from unmaintained actions-rs #build-linux

* no need to add rustfmt and clippy as they are now preinstalled on runner images

* linux: fix run build/test/fmt/clippy for each rust version #build-linux

* linux: make sure rustfmt and clippy are installed for non-stable toolchains #build-linux

* better implementation for is_http

* macos/windows: remove unmaintained actions-rs from build script #build-windows #build-macos

* wasm: remove unmaintained actions-rs from build process #build-wasm

* ios: remove unmaintained actions-rs from build process #build-ios

* android: remove unmaintained actions-rs from build process #build-android

* android: fix build #build-android

* android: fix build (try 2) #build-android

* android: fix android build after removal of actions-rs #build-android

* Remove unmaintained actions-rs from release build script [skip ci]

* force opening of browser on windows, instead of local file association

* fix lint for windows code

* on unix, detect default xdg browser and use that to bypass local file associations

* allow for selective builds during pushes

* tests: ensure wasm pkg dir #build-wasm

* tests: enable trace logging on all platforms

* fix wasm build #build-wasm #build-windows

* do not do the compilers job

* test for xdg open [skip-ci]

* tests: increase wait timeout on windows as github windows runner seems a bit slow #build-windows

* change internal signature to better handle url and local paths separately

* refactor TargetType

* move macos implementation to use CoreFoundation instead of open #build-macos

* define consistent behaviour to include opening web browser even for local files

* tests for local html file opening in browser

* fix wasm build #build-wasm

* fix wasm build (again) #build-wasm

* create the right url targettype for wasm #build-wasm

* fix linux and windows builds #build-linux #build-windows

* fix linux build #build-linux

* attempt #3 to fix linux build #build-linux

* update github action versions

* allow for optional hardened feature as a strict security precaution

* linux: move away from unmaintained actions-rs #build-linux

* no need to add rustfmt and clippy as they are now preinstalled on runner images

* linux: fix run build/test/fmt/clippy for each rust version #build-linux

* linux: make sure rustfmt and clippy are installed for non-stable toolchains #build-linux

* better implementation for is_http

* macos/windows: remove unmaintained actions-rs from build script #build-windows #build-macos

* wasm: remove unmaintained actions-rs from build process #build-wasm

* ios: remove unmaintained actions-rs from build process #build-ios

* android: remove unmaintained actions-rs from build process #build-android

* android: fix build #build-android

* android: fix build (try 2) #build-android

* android: fix android build after removal of actions-rs #build-android

* Remove unmaintained actions-rs from release build script [skip ci]

* wsl: make WSL implementation compliant with the Consistent Behaviour for files #build-linux

* wsl: allow for disabling of wsl file impl via disable-wsl feature #build-linux

* better documentation of library guarantees

* changelog: update for v0.8.3

* Release v0.8.3

* changelog: fix consistent behaviour link [skip ci]

* fix release process - include firefox test screenshot.png in .gitignore [skip ci]

* Add SECURITY.md [skip ci]

* windows: move away from ShellExecuteEx to AssocQueryStringW

* Release v0.8.4 [skip ci]

* changelog: add issue detail for the v0.8.4 release [skip ci]

* Upgrade windows-rs to 0.44

* Remove windows dependency

* android: uninstall previous version of test app before testing #build-android

* Release v0.8.5 [skip ci]

* Use correct call convention for AssocQueryStringW()

* tests: increase uri received check timeout to 90s given runner situation at github

* Release v0.8.6 [skip ci]

* changelog: reference the correct issues in v0.8.6 entry

* Bail from `try_xdg` if browser name is empty

* tests: ensure a delay before firefox can screenshot, so that we have a chance to execute the wasm url switch #build-wasm

* tests: satisfy fmt and clippy for test code

* Release v0.8.7 [skip ci]

* android: Upgrade `jni` to `0.21`

* tests/android: Use `adb reverse` to access host webserver, allow running on !macos

Instead of chaining a bunch of Unix commands to pry out the IP address
of a random adapter, that may not be available on every distro, use the
standard `adb reverse` command to forward a specific port from the
Android phone (or emulator) to the host, where the test-webserver is
running.  This makes the test-script host-independent (should in theory
run even on Windows now) and does not require the device at test (which
could be a regular Android phone if not having an emulator running) to
be connected to / reachable over the same network.

* android: Upgrade `jni` to `0.21`

* Release v0.8.8 [skip ci]

* fix scenario where windows browser command may not be quoted correctly #build-windows

* fix windows build #build-windows

* Provide support for flatpak. Fixes amodm#67. #build-linux

* gitignore: add .vscode

* Release v0.8.9 [skip ci]

* Bump 'dirs' dependency to 5.0

* Move to the smaller, cargo-team maintained `home` crate

* Release v0.8.10 [skip ci]

* keep gitpod patch

* format

---------

Co-authored-by: Panagiotis Vasilopoulos <hello@alwayslivid.com>
Co-authored-by: yazgoo <yazgoo@gmail.com>
Co-authored-by: Amod Malviya <amod@rootnet.in>
Co-authored-by: hossein <hosseind2017@gmail.com>
Co-authored-by: VZout <viktor.zoutman@embark-studios.com>
Co-authored-by: Henrik Rydgård <hrydgard@gmail.com>
Co-authored-by: tokusumi <tksmtoms@gmail.com>
Co-authored-by: Azorlogh <bott.alix@gmail.com>
Co-authored-by: hakolao <okkohakola@gmail.com>
Co-authored-by: Robert Bragg <robert@sixbynine.org>
Co-authored-by: Nachtalb <na@nachtalb.io>
Co-authored-by: Marijn Suijten <marijn@traverseresearch.nl>
Co-authored-by: Jake Shadle <jake.shadle@embark-studios.com>
Co-authored-by: alula <6276139+alula@users.noreply.github.com>
Co-authored-by: Krishna Ravishankar <25255817+krsh732@users.noreply.github.com>
Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
Co-authored-by: Utkarsh Gupta <utkarshgupta137@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants