mitoyarzun / zxingfragmentlib

Barcode scanner for Android fragments. Compatible with Android 2.1+.
Apache License 2.0
113 stars 44 forks source link

BarcodeScannerFragment Skipped 63 Frames! when swiping between 3 fragments #12

Open stephenohair opened 10 years ago

stephenohair commented 10 years ago

Great work for porting this to use fragments, thanks!

I have a 3 tab viewpager. The barcode is fragment item number 2.

I start my application and the default fragment item 0 is shown. When I swipe to fragment item 1 the barcode scanner stored as item number 2 starts up, maybe the viewpager is caching it I'm not sure. This causes a bit of processing to occur as the camera initializes in the background and the DecodeThread starts up. Now this is all happening as fragment item 1 is showing not the barcode scanner which is fragment item 2.

Due to this there is a moment of about 1 second or ~60 frames frames skipped while switching between fragment item 0 and 1.

Here is an extract of my logcat :

04-23 23:13:59.076: I/CameraConfiguration(21035): Settable value: off 04-23 23:13:59.076: I/CameraConfiguration(21035): Supported values: [infinity, auto, macro, continuous-video, continuous-picture] 04-23 23:13:59.076: I/CameraConfiguration(21035): Settable value: auto 04-23 23:13:59.076: I/DecodeThread(21035): Hints: {POSSIBLE_FORMATS=[CODABAR, CODE_39, CODE_93, CODE_128, DATA_MATRIX, EAN_8, EAN_13, ITF, QR_CODE, RSS_14, RSS_EXPANDED, UPC_A, UPC_E], NEED_RESULT_POINT_CALLBACK=com.welcu.android.zxingfragmentlib.ViewfinderResultPointCallback@430cc730} 04-23 23:13:59.136: I/PlatformSupportManager(21035): Using implementation class com.welcu.android.zxingfragmentlib.common.executor.HoneycombAsyncTaskExecInterface of interface com.welcu.android.zxingfragmentlib.common.executor.AsyncTaskExecInterface for SDK 11 04-23 23:13:59.136: I/AutoFocusManager(21035): Current focus mode 'auto'; use auto focus? true 04-23 23:14:00.006: E/MediaPlayer(21035): Should have subtitle controller already set 04-23 23:14:00.006: I/Choreographer(21035): Skipped 63 frames! The application may be doing too much work on its main thread. 04-23 23:14:00.536: W/MediaPlayer-JNI(21035): MediaPlayer finalized without being released

Do you know of a way to keep the barcode scanner fragment from continually stopping and starting when swiping though fragments please?

Many Thanks,

Steve

mitoyarzun commented 10 years ago

I haven't found a way to improve this, it happens to me too. What device are you using?

stephenohair commented 10 years ago

I'm using a Nexus 5 to test with. I ended up making some changes to the stop and start for the scanner fragment. It's still not perfect as there are some test cases I have to get working properly first like resuming from sleep etc... I'm using robotium to try and cover this with some automated ui testing.

rhavran commented 8 years ago

@SuperEvenSteven Try to put into your activity layout, then fragment should works fine.