-
Notifications
You must be signed in to change notification settings - Fork 408
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
Camera DisplaySurface does not reinitialize onStart for Some Devices #115
Comments
I have also seen this issue on a Nokia 5 and a Samsung galaxy S5. In my case, the workaround I tried from the set above did not work - the third option above, setting the content view in onStart. This may be because I also have some other asynchronous work running, including location updates which may affect the timing also if the root problem is a race condition. Any insights anyone has would be much appreciated... |
Note I think this issue raised previously is probably the same root problem also - #104 |
Interesting - that would suggest that none of the workarounds are completely safe (and obviously none of them are optimal, I am hoping someone with more experience than I, can use this info to find a real fix). I am curious to know, if you try the second workaround, 'Wait to call fotoapparatSwitcher.start on onStart' does it work? If not, if you try increasing the delay from 60ms to 400ms or something a lot bigger does it work? If so that would further suggest that the root problem is a race condition. |
I'm having the same issues when dealing with multiple switched between cameras and app switching. At some point, the screen remains white and if I check the cameraswitcher, it's state is initialised. |
Hi - Any update on this issue (and on - #104) |
You may try |
I ran a few tests with the 2.0.0 release on the Galaxy s6 (which was previously affected) and the issue appears to be resolved (the camera displaySurface always reinitialized)! In a couple days I will test it out on the s5 and v20 and report back if anything comes up, but I am guessing this release did the trick. I cannot thank you all enough for this great library! |
That's great news Andrew! I will mark this as resolved and if persists, feel free to comment again. Have a happy coding year! |
Im having similar issue, white screen on lenovo tab TB-X605L (android 9), |
You Guys Rock
First off, I am so grateful for Fotoapparat, it is an amazing library with excellent functionality and has been wonderful to work with.
The Issue
I've discovered that on some devices the camera view does not reinitialize (shows a white or black screen instead) when returning to the camera activity but it always initializes correctly the first time.
This can be reproduced with the Fotoapparat sample app in Android Studio with the emulator running a Nexus 5 on Android 5.1.1. If you load the sample app, hit the home button and then re-enter the app the camera view will be blank.
Testing with different versions of Fotoapparat from 1.4.1 back through 1.1 yields the same result (I did not test back farther).
The relevant logcat entries are
Confirmed Affected Devices
The devices I have confirmed are affected so far (non-emulated) are the LGv20, Galaxy S6 and Galaxy S5.
Some Workarounds
I tried my hand at finding the issue but was not able to pin it down precisely. I did discover some (bad) workarounds that may offer some insight.
Sleep before calling camera.setDisplaySurface(textureView);
If you sleep the thread temporarily in textureRendererView before calling setDisplaySurface the issue does not occur:
Furthermore adding in a small thread sleep anywhere in the StartCameraRoutine will also fix is the issue.
Wait to call fotoapparatSwitcher.start on onStart
On the user side the issue can be relieved by waiting a few ms before calling fotoapparatSwitcher.start() in onStart. For instance in onStart:
setContentView in onStart instead of onCreate
Another thing I tried that fixed the issue is to move setContentView from onCreate to onStart (along with the other dependent bits). Obviously not optimal but it is interesting. I am not sure if this is because it forces a reinit onStart or if it works because it effectively is delaying the call to fotoapparatSwitcher.start.
Final Thoughts
Thank you again for your great library. Hopefully my odd tests provide some insight. If there is anything further I can do please let me know. This issue seems similar to #77 but since it is reported fixed I am probably wrong. It also has some commonalities with #104 and #89. While the exact details are different I suspect the underlying cause may be similar.
The text was updated successfully, but these errors were encountered: