functionland / fx-fotos

"Fx Fotos" is an opensource gallery app in react native with the same smoothness and features of Google Photos and Apple Photos. It is backend gnostic and connects to decentralized backends like "box", "Dfinity", "Filecoin" and "Crust".
https://t.me/functionland
MIT License
672 stars 74 forks source link

fotos UI freezes when trying to connect #205

Closed gitaaron closed 2 years ago

gitaaron commented 2 years ago

It happens when Fotos is trying to upload a photo to the Box and it responds in a way that Fotos is not handling.

If I stop the Box application then the Fotos UI becomes responsive again.

To help reproduce it maybe you can just add a sleep in Box?

Mahdi mentioned that a background task did not solve the issue meaning it is probably entering an infinite loop and eating up cycles or something.

--- Want to back this issue? **[Post a bounty on it!](https://app.bountysource.com/issues/109775922-fotos-ui-freezes-when-trying-to-connect?utm_campaign=plugin&utm_content=tracker%2F206746002&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://app.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F206746002&utm_medium=issues&utm_source=github).
ghorbani-m commented 2 years ago

I did some investigation on how we can run a piece of code that blocks the Js thread on react-native and tried some packages like react-native-multithreading and react-native-bg-thread but none of them worked

What I understood we need to implement multi-threading on react-native-fula while streaming the data.

farhoud commented 2 years ago

@gitaaron @ghorbani-m

What I understood we need to implement multi-threading on react-native-fula while streaming the data.

Then we have 2 problems. :D

react native design single threaded and go-fula run on main UI thread (not JS thread). so the thing goes south it break the main thread. And by reading code of Libp2p dial and connect. ref you will see that libp2p already is multi thread code. So don't think adding thread fix's anything. I think the main reason on freezes is current go-fula-0.4.2 has some bug in error handling (the code will panic) that i will fix after. [ ] - https://github.com/functionland/go-fula/issues/18

ghorbani-m commented 2 years ago

@farhoud I don't think the freeze issue is because of some bugs or error handling on go-fula. I did some tests and called other blocker codes on Fotos and got the same result as calling go-fula methods.

My solution is to implement multi-threading on react-native-fula on the Java side while we are bridging the codes.

farhoud commented 2 years ago

@ghorbani-m The underlining code in go side is multi-threaded and if you still blocked means :

My experience is accept react-native framework limitation. ref

farhoud commented 2 years ago

I think the new architecture and JSI will solve the problem but they are at there early stage and not ready for production

ghorbani-m commented 2 years ago

@ghorbani-m The underlining code in go side is multi-threaded and if you still blocked means :

  • the react-native does not respect the module threading.
  • I don't think if the threading does not work on go side it would work on JAVA.

My experience is accept react-native framework limitation. ref

I added multi-thread feature to the react-native-fula androidmodule and got a test so it works like what we expect. @farhoud can you please have a look at this PR and if it is ok then merge it and release a new build?