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

Run the app in the background #54

Open
Imveryweird opened this issue Aug 7, 2020 · 20 comments
Open

Run the app in the background #54

Imveryweird opened this issue Aug 7, 2020 · 20 comments
Labels
enhancement New feature or request research needed This change requires some research first

Comments

@Imveryweird
Copy link

Imveryweird commented Aug 7, 2020

The last thing I want to do is stare at my phone for an extended period of time while trying to relax. If I want to go to sleep doing the 4-7-8 breathing technique (btw you also need a custom sleep timer), or if I'm in public trying to calm down, the last thing I wanna have to do is keep my phone screen on while its on my nightstand or in my pocket possibly burning the screen.

@mmazzarolo
Copy link
Owner

mmazzarolo commented Aug 7, 2020

Hey @Imveryweird , thanks for the feedback.
The reason why the app doesn't work in the background is because... it's complicated :)
If you know how to do it, we're open to pull requests and support 👍
I have a couple of ideas on how it could be achieved, but they would require a huge rewrite of the app.

@mmazzarolo mmazzarolo changed the title Play Breathing Exercises in The Backgroud as Audio Add support for running the app in the background Aug 7, 2020
@mmazzarolo mmazzarolo added the enhancement New feature or request label Aug 7, 2020
@G-i-o
Copy link

G-i-o commented Sep 27, 2020

HI @mmazzarolo,

First thank YOU very so much for this app and for providing it on F-Droid.

Then, I second @Imveryweird proposition very much. ATM I can only use this app at home or when I'm near a power socket because it drains so much battery.

I did not realize it was so much more difficult to make it run in the background since most apps can do this (i.e. all music players etc.) but if that is problematic maybe you could make it to allow export of audio files? So, one could chose all the preferred settings (time + session) and export the audio file to be played with a normal player.

On a side note, I don't know if I should create another ISSUE for this but since I downloaded this from F-Droid, I'd like to make a donation to support the development and as a thank YOU. The easier, most private and safest way for both donors and you, would be to have a cryptocurrency address (or better, few, like Ethereum, Cardano, Tron, Litecoin, a stablecoin etc.) where to send the funds. Maybe you could add one either on the F-Droid page or in an ABOUT page (currenlty missing) on the app itself.

Thank YOU again.

@mmazzarolo
Copy link
Owner

First thank YOU very so much for this app and for providing it on F-Droid.

Thank you! Is the F-Droid version up-to-date? I wasn't the person who originally posted it on F-Droid and I don't know how to update it there :/

I did not realize it was so much more difficult to make it run in the background since most apps can do this (i.e. all music players etc.)

Yeah, there are a couple of reasons for it being "difficult":

  1. The app architecture wasn't built with the "guided meditations" in mind. They were added only later on after they have been requested. This means that adding support for the exercises to un in the background requires a non-trivial rewrite of parts of the app.
  2. The app "framework" (react-native) used by Breathly doesn't offer any tool to run the app in the background out of the box. So it won't be as easy as it would be for other app features.
  3. (Because of 2) It would probably require some native work on both Android and iOS, and I'm not that good at iOS development 😬

I'm still looking into it from time to time and I have a couple of ideas on how to tackle this work. I just need to find some time to actually give it a try.

but if that is problematic maybe you could make it to allow export of audio files? So, one could chose all the preferred settings (time + session) and export the audio file to be played with a normal player.

That's a smart idea, but I think that would be even more difficult to implement natively. But maybe it could be done on the server-side... 🤔 Let me think about it.

On a side note, I don't know if I should create another ISSUE for this but since I downloaded this from F-Droid, I'd like to make a donation to support the development and as a thank YOU. The easier, most private and safest way for both donors and you, would be to have a cryptocurrency address (or better, few, like Ethereum, Cardano, Tron, Litecoin, a stablecoin etc.) where to send the funds. Maybe you could add one either on the F-Droid page or in an ABOUT page (currenlty missing) on the app itself.

Thank you 😊 But currently I'm not accepting any donation.

@mmazzarolo
Copy link
Owner

mmazzarolo commented Sep 27, 2020

but if that is problematic maybe you could make it to allow export of audio files? So, one could chose all the preferred settings (time + session) and export the audio file to be played with a normal player.

Now that I think about it, do you have any idea of how the other breathing apps run in the background? Do they just run the exercise like if it was an audio track?

@mmazzarolo
Copy link
Owner

(On a side note, I created #60 to track the F-Droid support)

@G-i-o
Copy link

G-i-o commented Sep 27, 2020 via email

@G-i-o
Copy link

G-i-o commented Sep 27, 2020 via email

@mmazzarolo mmazzarolo changed the title Add support for running the app in the background Run the app in the background Sep 27, 2020
@mmazzarolo
Copy link
Owner

mmazzarolo commented May 15, 2021

Just wanted to suggest few apps that run in the background with screen on or off. As they are opensource, you might be able to take some of their code and integrate it into Breathly just with some adjustment rather than having to make "several changes"?

Lineage own Music Player
OpenTracks
OsmAnd~
AudioAnchor

Thanks @G-i-o for the examples -- unfortunately, they won't help too much for this case.

To add some more context, there are three main problems "blockers" for this feature to be implemented:

  1. We're using React-Native Run the app in the background #54 (comment)
  2. The "audio" that we need to run is not a single track. Audio player just have to play a single track in the background (or multiple tracks one after another). In our case we have multiple tracks (breathe-in, breathe-out, hold, end bell) that must be played with a delay/silence in between them. And to add one more complexity on top of it, the delay/silence and the exercise length can be customized by the user. Normally, apps that need to do something like this (e.g.: mediation apps) create multiple tracks of specific lengths (e.g.: 5 minutes meditation, 10 minutes meditation) but they all run with fixed timings. In our case, it's not possible because we would have to support n track for every possible combination (or generate them on the spot on the app, which is surely even more complex to do).
  3. Not enough free time to work on. Especially knowing it would be very time consuming because of ☝️.

@G-i-o
Copy link

G-i-o commented May 15, 2021

@mmazzarolo
I see. However, your description seems to apply solely to the audio players. Maybe OpenTrack works more similarly to Breath as the announcements have an adjustable time between them and they always say something different (Voice synthesized, though).

Also, something it's better than nothing. If the variety of adjustable session settings makes it more complicated, I guess better having at least a couple of sessions with fixed values that can work in the background than nothing.

I also guess from your comment that exporting the session would meet the same difficulties.

What about darkening the screen to simulate turning-off. The app would be running on the foreground as now but the screen would be off and then brought back/re-adjusted to the initial luminosity setup. Would that be easier?

Finally, I do personally appreciate your work and your time constraints. I hope more volunteering devs will like to join and help with the development.

🙏🏼

@mmazzarolo
Copy link
Owner

Maybe OpenTrack works more similarly to Breath as the announcements have an adjustable time between them and they always say something different (Voice synthesized, though).

I think OpenTrack is Android-only though, right? 🤔

Also, something it's better than nothing. If the variety of adjustable session settings makes it more complicated, I guess better having at least a couple of sessions with fixed values that can work in the background than nothing.

I (kinda) disagree. Half-baked solutions sometimes work but also expand the scope of the app making it even harder to maintain. And the more features you add, the higher the expectations people will have: just as an example, adding the guided meditation LOWERED the score of the app on the play store because people expected the voice to also run in the background. If I need to spend some time on a feature, personally, I prefer to make it work consistently across both iOS and Android. Of course if someone else would like to join and develop a half-baked solution, that would be a different story :)

I also guess from your comment that exporting the session would meet the same difficulties.

Yep :/

What about darkening the screen to simulate turning-off. The app would be running on the foreground as now but the screen would be off and then brought back/re-adjusted to the initial luminosity setup. Would that be easier?

Yeah, this + the OLED rework could be a nice tradeoff. Not 100% sure what can be done on the iOS part for that though, I'll investigate 👍 thanks

@G-i-o
Copy link

G-i-o commented May 15, 2021

Yeah, was not even aware (Or maybe forgotten) this was also on Google store + Apple store.

I agree on the expectations and if ratings are important to you, that's a different story. My comment was from the user's perspective....and not your typical Google/Apple user either, who maybe less appreciative.

All, in all whatever works and takes less effort.....time constraints in mind, as mentioned. 🙏

@mmazzarolo
Copy link
Owner

I agree on the expectations and if ratings are important to you, that's a different story. My comment was from the user's perspective....and not your typical Google/Apple user either, who maybe less appreciative.

To clarify: it's not much about what the rating of the app is, it's more about the reasons behind the ratings. I don't care that much if ratings drop, and I even agree with those users. Adding half-baked features creates unrealistic expectations: we're not supporting running the app in the background, we're only supporting running a handful of combinations... which would probably meet < 5% of the use cases.
How should we pick these use cases? What pattern + voice + length should we run in the background?
I don't see how this would scale 🙁

(Just my 2 cents — I genuinely appreciate discussing this topic, thanks for contributing 👍 )

@G-i-o
Copy link

G-i-o commented May 15, 2021

I guess you always have to start somewhere. I'm not expert of both those app stores and the technicalities of developing what discussed here. However, you should be able to clarify in the description that certain features are at very early stage of development and improvements may come at a slower pace according to your time constrains. In my experience, customers/users always appreciate clarity.
After all, no app/piece of software is fully developed with all functions and in perfect state on the first versions. As long as the description clearly says what the app does, it should not be a big problem and people should not be disappointed. A user should not mark you down for something you have not committed to.

As for picking the starting point with the use cases, I might be wrong here, but the difficulty is at the beginning when you have to set the framework to support it. Once it's done for one, adding more cases should not be so time consuming and difficult. Also, you can start adding the first one or two sessions, in the order they are right now. If creating more does not involve programming knowledge, I'd be happy to help.

Finally, I also appreciate your being open to discuss 🙏 ....and if darkening the screen or other proposed alternatives work better for you, I'm all for them.

@mmazzarolo
Copy link
Owner

My understanding of this:

I guess better having at least a couple of sessions with fixed values that can work in the background than nothing.

Was to manually create the tracks for a few sessions. Meaning that we won't setup a "framework" as you mentioned below 👇

As for picking the starting point with the use cases, I might be wrong here, but the difficulty is at the beginning when you have to set the framework to support it. Once it's done for one, adding more cases should not be so time consuming and difficult.

So adding more cases would mean doing the entire same manual process again. That's why I don't think it would be scalable.
Maybe I misunderstood your suggestion?

@G-i-o
Copy link

G-i-o commented May 15, 2021 via email

@mmazzarolo
Copy link
Owner

mmazzarolo commented May 15, 2021

For my limited knowledge in the specific subject,
when you do make a couple of sessions with fixed
values and then want to add more, you don't need
to start from scratch. The path is already set.

The process can definitely be automated, but we would still hit the scaling problem, right?
We have an enormous amount of combinations to support, and also: where should these be stored? As I mentioned in an old comment, I think storing them on the client is not a valid option because it would increase the app size a lot. And even storing them on the server would not be possible given the number of permutations. Storing them on the server would also introduce a UX/design question (when/how should they be downloaded?) but it's definitely something we can find a solution for.

In all honesty, the more I think about it, the more I feel like the right path here is to either generate them on the fly on the client or on the server. What do you think?

@G-i-o
Copy link

G-i-o commented May 15, 2021 via email

@G-i-o
Copy link

G-i-o commented May 16, 2021

So, I've done some research and some thinking and I have few points to add:

• Manually building pre-made tracks can be done but it'd be awkward indeed. This should be kept only as very last resort after all other alternatives have been tried first.
• There's an opensource audio file manipulator tool called SOX (see here:http://sox.sourceforge.net/sox.html) that, among many things, allows the merging of different audio files into one single track and automatic creation of silence audio files of different lengths (Here it shows how to create silence files: http://activearchives.org/wiki/Padding_an_audio_file_with_silence_using_sox).

So, in reference to the last point, SOX could be used by BREATHLY to create fixed-value as well as customized sessions and have them saved into a single audio track. If I'm correct, according to what you previously mentioned, this should bring BREATHLY at pair with any normal audio player and thus make running it in the background / with screen off a simple task ?

@mmazzarolo
Copy link
Owner

Thanks for the research 🙏

I also spent some time thinking through this and I'm now 100% sure that the only way this should land (unless someone else actively develops an alternative solution) is if we can make it run on the client only AND support all configurations AND both Android/iOS. So either build tracks on the fly on the client or find a way to orchestrate the different tracks in the background while the screen is off.

So, in reference to the last point, SOX could be used by BREATHLY to create fixed-value as well as customized sessions and have them saved into a single audio track.

🤔 I'm not sure I'm following how? Does SOX run on iOS and Android (and has a React-Native bridge)?

If I'm correct, according to what you previously mentioned, this should bring BREATHLY at pair with any normal audio player and thus make running it in the background / with screen off a simple task ?

It would definitely not be a simple task, but at least it would be doable 👍 We're still talking of multiple hours of work (between implementation for supporting both platforms + testing).

@G-i-o
Copy link

G-i-o commented May 16, 2021

thinking I'm not sure I'm following how? Does SOX run on iOS and Android (and has a React-Native bridge)?
You are right, sorry. SOX only runs on Linux for now. However, I think the libraries it uses run on Android too.
Even so, I'm not familiar at all with IOS system nor with React-Native.

I agree on everything else you said. So, I guess the most feasible and quickest way to circumvent this issue would be optionally having the client turn the luminosity down to zero and then up to the previous level once the session has ended.
Also (I think this might have been suggested already), a full dark mode should also come to help in terms of battery drainage.

@mmazzarolo mmazzarolo added the research needed This change requires some research first label Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request research needed This change requires some research first
Projects
None yet
Development

No branches or pull requests

3 participants