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

setParamaters Crash on Haiwai,1.0.2 #48

Closed
markGilchristBookingBug opened this issue Jun 28, 2017 · 13 comments
Closed

setParamaters Crash on Haiwai,1.0.2 #48

markGilchristBookingBug opened this issue Jun 28, 2017 · 13 comments
Labels
Projects

Comments

@markGilchristBookingBug

Fatal Exception: java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Camera.java)
at android.hardware.Camera.setParameters(Camera.java:2028)
at io.fotoapparat.hardware.v1.Camera1.updateParameters(Camera1.java:178)
at io.fotoapparat.routine.StartCameraRoutine.run(StartCameraRoutine.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:838)

@dmitry-zaitsev
Copy link
Member

Could you please provide us with more logs from the device? In particular, I am interested in logs with tag Fotoapparat

@markGilchristBookingBug
Copy link
Author

markGilchristBookingBug commented Jun 29, 2017

screen shot 2017-06-29 at 09 20 33

All I have from crashlytics is the logs from above none of the other threads reference Fotoapparat

@dmitry-zaitsev
Copy link
Member

When creating Fotoapparat instance, you can specify the Logger. In this logger, you can try to write more information to Crashlytics.

@dmitry-zaitsev
Copy link
Member

Few more generic questions which should help us to analyze the problem:

  • Is app always crashing on this model? Or were there some successful sessions?
  • Do you have more related crashes on the same type of the device? Or is it just this one user?

@dmitry-zaitsev
Copy link
Member

@markGilchristBookingBug In the meanwhile, please try updating to 1.0.3. It will not fix the problem itself, but it will include more information into exception's message.

@arekolek
Copy link

arekolek commented Jul 6, 2017

I have the same issue (exactly the same stack trace). I've added Crashlytics logging and upgraded to ver. 1.0.3 of Fotoapparat, maybe tomorrow I'll have something interesting to share.

Crashlytics reports that 11 users on 6 different device models are affected in my case. The phone models being:

  • CHC-U01 (Huawei G Play Mini)
  • GT-I9060I (Samsung Galaxy Grand Neo)
  • GT-I9195 (Samsung Galaxy S4 mini)
  • GT-S7580 (Samsung Galaxy Trend Plus)
  • SM-G355HN (Samsung Galaxy Core 2)
  • SM-J100H (Samsung Galaxy J1 Duos)

At the moment, I don't have a way of saying whether any of those models had a successful session.

Because there are more users than models, I suspect that there must be multiple users affected by this issue on some device models.

@Diolor
Copy link
Member

Diolor commented Jul 6, 2017

Hi @markGilchristBookingBug + @arekolek,

How do you set the preview sizes? Potentially it's the same issue with this SO question.

@arekolek
Copy link

arekolek commented Jul 7, 2017

@Diolor I just have the CameraView in my layout:

<io.fotoapparat.view.CameraView
        android:id="@+id/camera_preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

and set it up like this in my fragment:

@BindView(R.id.camera_preview) CameraView cameraPreview;
private Fotoapparat fotoapparat;

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    ButterKnife.bind(this, view);
    fotoapparat = Fotoapparat.with(getActivity())
            .into(cameraPreview)
            .photoSize(biggestSize())
            .lensPosition(front())
            .focusMode(firstAvailable(
                    continuousFocus(),
                    autoFocus(),
                    fixed()
            ))
            .logger(new Logger() {
                @Override
                public void log(String msg) {
                    Crashlytics.log(Log.DEBUG, "Fotoapparat", msg);
                }
            })
            .build();
}

@Override
public void onStart() {
    super.onStart();
    fotoapparat.start();
}

I'm not doing anything with Camera.Parameters directly in my code, so it's whatever Fotoapparat does by default (which is biggestSize() from what I see).

@dmitry-zaitsev
Copy link
Member

It seems (obviously) that Camera is not happy with whichever parameters we are passing to it. At the moment we try to update the whole set of parameters at once, so it's hard to tell which property causes the issue exactly.

I'll create a fallback mechanism which will try to update each parameter individually and log/suppress the failures. Expect the new versions until the end of the week.

Another topic. I see you are tracking Fotoapparat logs in Crashlytics. Is there any chance you can share those with us?

@dmitry-zaitsev
Copy link
Member

The experimental fix is ready. You can try it out now in new version 1.1.0.

@arekolek
Copy link

arekolek commented Jul 10, 2017

@dmitry-zaitsev I've added Crashlytics only recently, but got some reports over the weekend. Looks like they got obfuscated by ProGuard, but there were only at most three lines there anyway, so I guess those must be:

07-10 12:10:41.700 1755 2487 D Fotoapparat: open
07-10 12:10:41.862 1755 2487 D Fotoapparat: getCapabilities
07-10 12:10:41.868 1755 2487 D Fotoapparat: updateParameters

Sometimes all three, sometimes only two first, other times only the first, and sometimes none. Additionally, the exception message is more informative now and says:

io.fotoapparat.hardware.CameraException: Failed to set parameters:
       Parameters{values={FLASH=OFF, FOCUS_MODE=FIXED,
              PREVIEW_SIZE=Size{width=1280, height=720},
              PICTURE_SIZE=Size{width=1920, height=1080}}}
       at io.fotoapparat.hardware.v1.Camera1.throwOnFailSetParameters(SourceFile:59)
       at io.fotoapparat.hardware.v1.Camera1.updateParameters(SourceFile:196)
       at io.fotoapparat.routine.StartCameraRoutine.run(SourceFile:40)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:841)
Caused by java.lang.RuntimeException: setParameters failed
       at android.hardware.Camera.native_setParameters(Camera.java)
       at android.hardware.Camera.setParameters(Camera.java:1753)
       at io.fotoapparat.hardware.v1.Camera1.updateParameters(SourceFile:194)
       at io.fotoapparat.routine.StartCameraRoutine.run(SourceFile:40)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at java.lang.Thread.run(Thread.java:841)

That's on Samsung Galaxy S4 mini (GT-I9195). On ASUS MeMO Pad HD 7 (ME173X) the parameters were: {FLASH=OFF, FOCUS_MODE=FIXED, PREVIEW_SIZE=Size{width=1280, height=960}, PICTURE_SIZE=Size{width=1280, height=960}}

Which kind of makes sense, considering S4 mini has a 540x960 px display and ASUS has a 800x1280 px display (from what I could find), so the requested preview size is bigger than the display in both instances. But it baffles me why would Camera.Parameters.getSupportedPreviewSizes() return such sizes in that case.

I'll try to keep ProGuard from obfuscating the logs and update Fotoapparat to 1.1.0 and we'll see what happens.

I've added this to my proguard-rules.pro:

-keepnames public class io.fotoapparat.** { *; }

So far it looks like it does the job, not sure if there's anything more needed.

@dmitry-zaitsev
Copy link
Member

Wow, that's really helpful!

Which kind of makes sense, considering S4 mini has a 540x960 px display and ASUS has a 800x1280 px display (from what I could find), so the requested preview size is bigger than the display in both instances

That is actually OK, preview stream might have higher resolution than the screen itself.

I am very suspicious about FOCUS_MODE=FIXED - that is a rather unusual parameter and we use it by default if no other focus mode is specified. I assumed that it is supported by all devices, but apparently that is not the case. I will try to fix that.

Either way, latest release (1.1.0) will fix that issue since invalid parameters will just be suppressed. Not ideal from code perspective, but will do until we'll roll out the proper fix.

@dmitry-zaitsev
Copy link
Member

The way it is implemented right now seems to be quite robust, so I am closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
1.3.0
TODO
Development

No branches or pull requests

4 participants