Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Conversation

awaken1ng
Copy link
Contributor

This implements audio timing, although, a little bit in a hacky fashion.
Drastically reduces audio latency from 1-2 seconds to ~46 ms.
(~23 ms playing, the other ~23 ms in buffer, if I'm not mistaken)

Idea is to block the Android audio thread by reading from the socket after submitting the audio data.
The sink after receiving the data, places it into queue and responds to Android.
If queue is full, then it will block until data is written, delaying audio thread for as long as needed.

Copy link
Member

@morphis morphis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

I will merge as soon as I do a rebuild of the Android image.

@BobbyWibowo
Copy link

Hope to see this merged soon, cause I succ at building this myself.

@stale
Copy link

stale bot commented Nov 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the decaying label Nov 13, 2019
@stale stale bot closed this Nov 20, 2019
@morphis morphis reopened this Nov 23, 2019
@stale stale bot removed the decaying label Nov 23, 2019
@TheBITLINK
Copy link

So when is this getting merged?

@bryango
Copy link

bryango commented Feb 21, 2020

This patch is great, finally making Anbox usable for me. Please merge soon if possible!

@pingplug pingplug mentioned this pull request Apr 11, 2020
@PureTryOut
Copy link

I will merge as soon as I do a rebuild of the Android image.

@morphis, I guess the last image has been more than a year then. Please build a new one and merge this!

@Simbi0z
Copy link

Simbi0z commented May 2, 2020

please merge this!

@SiamSami
Copy link

SiamSami commented Jun 8, 2020

@morphis When are you going to merge this?

@stale
Copy link

stale bot commented Oct 10, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the decaying label Oct 10, 2020
@PureTryOut
Copy link

PureTryOut commented Oct 10, 2020

Please don't close this, it has gotten no reaction from the maintainer of Anbox since ages but is still desperately wanted.

@morphis please merge this at some point, you already said it looks good.

@stale stale bot removed the decaying label Oct 10, 2020
@Niek
Copy link

Niek commented Nov 9, 2020

+1 for merging this

@bertho-zero
Copy link

This is the only thing that bothers me when playing LDOE on PC

@Overc1ocker
Copy link

You mentioned that you wanted to build a new version of android when merging this. What is the status of that? Can we do anything to help?

@Niek
Copy link

Niek commented Nov 24, 2020

You mentioned that you wanted to build a new version of android when merging this. What is the status of that? Can we do anything to help?

@Fincer has a patched image with this PR included: https://fjordtek.com/public/applications/anbox/images/android_7.1.1_r13_patched.img

@bertho-zero
Copy link

I replaced the image and restarted the service, it does not improve the sound delay.

@Fincer
Copy link

Fincer commented Nov 24, 2020

@Niek

Yes, and to be more open about the image content itself, as someone may have security concerns:

All Android image patch files and rough build process steps I've used for the linked image file are described here:

https://fjordtek.com/git/Fincer/anbox-install/src/branch/master/androidOS_files

Whoever wants to compile the image him/herself, can do so. The only downside is HUGE size of downloadable AOSP source code, ~300 gigabytes.

I want to be very open about the image build process, and which parts of the image file have actually been changed compared to vanilla Anbox Android image file. I fully understand doubts of downloading a image file from non-GitHub location, therefore I absolutely prefer openness in sharing information as much as I can.

To be honest, I'd prefer if Anbox project officially could host a patched image file, whoever compiles it. It's not that much effort if the build environment requirements are met. Compiling the image takes ~3-4 hours on my laptop, for instance.

@bertho-zero

That doesn't sound good. For me, the patched image file fixes playback issues of NewPipe YouTube streams. What is your use case, i.e. the Android application you use?

@bertho-zero
Copy link

@Fincer Thank you for your reply, I'm trying to play Last Day On Earth.

@dos1
Copy link
Contributor

dos1 commented Nov 24, 2020

FWIW I've made an automated builder that includes this patchset by default: https://source.puri.sm/sebastian.krzyszkowiak/anbox-image-builder/

It works great for me and it does improve audio latency significantly, but of course you need this patchset to be applied to both the image and Anbox itself.

@Fuseteam
Copy link

oh dear this has a conflict now

@TheWeirdDev
Copy link

TheWeirdDev commented Jun 29, 2021

@Fincer has a patched image with this PR included: https://fjordtek.com/public/applications/anbox/images/android_7.1.1_r13_patched.img

I've built an ArchLinux package that works with this image. Give it a try.

You'll need a kernel that supports anbox and lxc version 4.0.6 or older.

The patch used in this build is taken from 👇

Edit: for those looking for a patch for current master: https://github.com/Niek/anbox/commit/41f5b77e10c1b66d537c8ac0288c4b477a199f86.patch

@TheBITLINK
Copy link

TheBITLINK commented Jun 29, 2021

Honestly surprised no one has forked this yet, something as essential and requested as better audio latency for proper video playback and games has been held back by 2 and a half years for no apparent reason.

With the announcement that Windows 11 will support Android apps, soon most other popular OS (Windows, Chrome OS and macOS) will have a way of running mobile apps with ease, in an integrated manner.

Yet Linux, in which Android is based of, is still missing features as basic as this for Android apps, and most games don't run yet out of the box (and it's not like they can't run, you just need to mess with command line parameters in order to make them work)

Anbox is a good project, don't get me wrong, but there hasn't been any noticeable significant improvements for years (just under the hood, minor stuff) while PRs like this have been years in limbo just because. There hasn't even been an official response from the maintainer yet (other than the "will merge after next rebuild" we got years ago). No ETA, no justification, nothing. This PR has been ignored for years and I'm sure many others are facing similar issues.

Seeing how many other open source projects have been forked for similar management shenanigans, it really comes as a surprise to me there hasn't been any notable forks yet.

@PureTryOut
Copy link

Just for the sake of it, let's ping @morphis again.

@Fuseteam
Copy link

@TheBITLINK the 938 forks say hi :P
Jokes aside there are a number of approaches for running android apps on linux using what anbox has done there is
AinD, remote-droid, Anbox Halium and such. the issue you are actually seeing is that non of them are actually doing what you are expecting out of anbox yet, due to the complexity of the whole thing and the few people capable of doing the work needed. Microsoft is a billion dollar company anbox and friends are developed by volunteers in their spare time. granted Anbox Halium is making more strides these days due to the extensive android experience of that dev.

this PR was "held back" because the maintainer hasn't found the time to rebuild the images anbox uses to make use of this, building android images can be pretty time consuming process sadly. just cloning the needed files can take up to 100GB!
While i do hope he does rebuild the image some time soon, there are a lot of improvements in the past 2 years that would benefit from it, i have no idea how he did build the images back then and what it will require of him right now.

if anything i think that if we can figure out a way to set up a CI for building the image somehow it could help the maintainer greatly when it comes to this

@dos1
Copy link
Contributor

dos1 commented Jun 30, 2021

@Fuseteam Some time ago I've prepared a builder based on Docker to produce Anbox images: https://source.puri.sm/sebastian.krzyszkowiak/anbox-image-builder/ In fact it even allows to effortlessly patch the image and includes this particular MR by default. It does arm64 images because that's all I cared about, but it could be of course adjusted.

I haven't used it in last few months though so hopefully it still works ;)

@Fuseteam
Copy link

Fuseteam commented Jun 30, 2021

@dos1 cool maybe you can make a PR to https://github.com/anbox/platform_manifests so that it builds automatically from there using that in a CI or something hehe

@Fuseteam Fuseteam mentioned this pull request Aug 2, 2021
@puyoxyz
Copy link

puyoxyz commented Sep 16, 2021

??????????????????

@T2hhbmEK
Copy link

@dos1

@Fuseteam Some time ago I've prepared a builder based on Docker to produce Anbox images: https://source.puri.sm/sebastian.krzyszkowiak/anbox-image-builder/ In fact it even allows to effortlessly patch the image and includes this particular MR by default. It does arm64 images because that's all I cared about, but it could be of course adjusted.

I haven't used it in last few months though so hopefully it still works ;)

I've forked this project and make it work on arch linux x86_64.
Here's my fork T2hhbmEK/anbox-image-builder.
I've compiled a working img and upload it to the github release.

@Niek

For one, the PR is no longer mergeable. @awaken1ng can you rebase with master?

Edit: for those looking for a patch for current master: https://github.com/Niek/anbox/commit/41f5b77e10c1b66d537c8ac0288c4b477a199f86.patch

The working anbox source code for this image is T2hhbmEK/anbox (niek branch).
I've rebased Niek/anbox on top of upstream code.

HOW TO
For arch linux users only.

  1. Have a working vanilla anbox installed.
  2. Just clone https://aur.archlinux.org/anbox-git.git and edit the PKGBUILD file to use T2hhbmEK/anbox (niek branch). Remember to git checkout niek in prepare function. Then build and install it(makepkg -si).(sample PKGBUILD)
  3. Stop anbox-container-manager.service
  4. replace /var/lib/anbox/android.img with github release.
  5. Start anbox-container-manager.service

Done. Enjoy anbox without audio lag.

@T2hhbmEK
Copy link

Since the anbox project owner does NOT have resources/willingness to build a new image.
Maybe, It's more reasonable to make audio timing implementation COMPATIBLE with vanilla Anbox image.
So that this merge request could be merged.
And anyone want the audio timing feature can build the image themself, or get the image from third party.
Just a thought.

@TheWeirdDev
Copy link

Maybe it's time to deprecate Anbox now that the Waydroid project has matured. I tested audio/video playback and it works fine. The only issue is with nvidia drivers not being supported which can be fixed using software rendering.

@clebercasali
Copy link

Maybe it's time to deprecate Anbox now that the Waydroid project has matured. I tested audio/video playback and it works fine. The only issue is with nvidia drivers not being supported which can be fixed using software rendering.

Maybe that's because Waydroid doesn't work with xorg (I wish it did), and nvidia has just started to support Wayland.

@T2hhbmEK
Copy link

T2hhbmEK commented Oct 15, 2021

Maybe it's time to deprecate Anbox now that the Waydroid project has matured. I tested audio/video playback and it works fine. The only issue is with nvidia drivers not being supported which can be fixed using software rendering.

Waydroid is still called anbox-halium when i check out weeks ago. And it had no docs.
It seems much mature now. Going to check it out soon.

@puyoxyz
Copy link

puyoxyz commented Oct 16, 2021

Maybe it's time to deprecate Anbox now that the Waydroid project has matured. I tested audio/video playback and it works fine. The only issue is with nvidia drivers not being supported which can be fixed using software rendering.

Waydroid doesn't work on Nvidia because of driver issues :( I wouldn't even be paying attention to this issue if Waydroid worked for me because it seems so much better

@TheWeirdDev
Copy link

Maybe it's time to deprecate Anbox now that the Waydroid project has matured. I tested audio/video playback and it works fine. The only issue is with nvidia drivers not being supported which can be fixed using software rendering.

Waydroid doesn't work on Nvidia because of driver issues :( I wouldn't even be paying attention to this issue if Waydroid worked for me because it seems so much better

I'm using it with my nvidia gpu using software rendering and honestly it still works better than anbox and feels even smoother. You don't need wayland too, just open a weston window inside your Xorg session and run it in there.

@T2hhbmEK
Copy link

Maybe it's time to deprecate Anbox now that the Waydroid project has matured. I tested audio/video playback and it works fine. The only issue is with nvidia drivers not being supported which can be fixed using software rendering.

Waydroid doesn't work on Nvidia because of driver issues :( I wouldn't even be paying attention to this issue if Waydroid worked for me because it seems so much better

I'm using it with my nvidia gpu using software rendering and honestly it still works better than anbox and feels even smoother. You don't need wayland too, just open a weston window inside your Xorg session and run it in there.

For those gamers' concern, I'm using Anbox for gaming. I've tried Waydroid. At present, It does not support hardware rendering for my RX 6600 XT. So still waiting for improvements until I can switch to Waydroid.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the decaying label Apr 16, 2022
@Fuseteam
Copy link

The changes are still approved, tho it has a conflict now

@cobalt2727
Copy link

LGTM, thanks

I will merge as soon as I do a rebuild of the Android image.

@morphis when can we expect this to happen?

@JamiKettunen
Copy link

when can we expect this to happen?

@cobalt2727 Never, all the repositories under the anbox group are now in 2023 effectively "archived" and nothing will be done about them any longer, see https://github.com/anbox#important---hi-there- for more details.

@enderprism
Copy link

Can this patch be reworked to work with Waydroid? Because Waydroid has the same audio latency issues.

@dos1
Copy link
Contributor

dos1 commented May 5, 2023

This patch is irrelevant for Waydroid as it implements audio in a completely different way and doesn't suffer from the issue this patch was fixing at all.

@cobalt2727
Copy link

Last time I used Waydroid I remember the audio being a couple seconds late - so it has the same problem as this patch, just in a different way? Are there any issues/PRs open for that?

@T2hhbmEK
Copy link

T2hhbmEK commented May 6, 2023

Are there any issues/PRs open for that?

waydroid/waydroid#613

@cobalt2727
Copy link

Totally forgot about that one (looks like I even commented on it last year). Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.