CameraEx and Service module

sangee

Member
Licensed User
Longtime User
I have been working on a app which takes pictures using the internal camera which gets stored in the memory card under the path /downloads/a3a/images".

I have a service module which gets triggered once every 10 seconds which calls a sub that makes a list of file to upload and using httputils2 post the files are uploaded one by one to the webserver. The webserver has a PHP which receives and stores the files in correct path.

All the above works well when i start the app. In between randomly the program gets stuck with a error below...

HTML:
Sorry!. Activity A3A CamService(in application A#A Camservice) is not responding. option buttons Force close and Wait.

After the above error the service just pauses and images are not clicked. I dont know where exactly the error is occurring.. I am uploading the project as a exported zip. Can anyone please go through this and let me know what needs to be done to prevent the service from hanging up when error is thrown and how can i restart the app when a error is encountered.

Thanks in advance..

Sangee
 

Attachments

  • a3a_camservice.zip
    13.4 KB · Views: 305

wheretheidivides

Active Member
Licensed User
Longtime User
is it after 3 pictures or 3 restarts of program? I have same problem with example. Probably you are re-inting. Basically, there is so much memory and if you don't release it then it keeps using up more and more until it crashes. I usually get a bitmap error, but it has nothing to do with it. I'm just guessing here.
 
Upvote 0

sangee

Member
Licensed User
Longtime User
Its very random.. sometimes it just continues for a long time. I guess i am making some mistake in the way i am using the camera .. and something wrong in the timing...
 
Upvote 0

sangee

Member
Licensed User
Longtime User
Hello Erel,

Thanks for looking into this... The lines from the log is as below..



HTML:
** Service (a3a_camservice) Start **
** Service (a3a_camservice) Start **
** Service (a3a_camservice) Start **
running waiting messages (1)
0
cameraexclass_startpreview (B4A line: 106)
cam.StartPreview
java.lang.NullPointerException
   at anywheresoftware.b4a.objects.CameraW.StartPreview(CameraW.java:143)
   at a3a.camservice.cameraexclass._startpreview(cameraexclass.java:866)
   at a3a.camservice.main._camera1_ready(main.java:421)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
   at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:798)
   at anywheresoftware.b4a.keywords.Common.CallSub2(Common.java:783)
   at a3a.camservice.cameraexclass._camera_ready(cameraexclass.java:130)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
   at anywheresoftware.b4a.BA$3.run(BA.java:301)
   at anywheresoftware.b4a.BA.setActivityPaused(BA.java:371)
   at a3a.camservice.main$ResumeMessage.run(main.java:210)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3683)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
** Service (a3a_camservice) Start **


This is when the camera becomes dead.. only phone restart gets back the camera to working condition.


HTML:
0: Jan 27 05:36:34 pm a3a.camservice
1: Jan 27 05:50:45 pm com.google.android.gsf
2: Jan 28 12:00:00 am com.whatsapp
3: Jan 28 12:01:00 am os.tools.scriptmanager
4: Jan 28 02:25:04 pm com.android.providers.calendar
5: Jan 28 04:24:05 pm com.android.googleapsvc
6: Feb 02 09:25:14 pm com.google.android.gsf
7: Feb 03 04:23:58 pm com.android.packageupdate
8: Feb 03 04:23:59 pm com.android.platsyncsvc
9: Feb 03 04:24:04 pm com.google.android.partnersetup
10: Feb 03 04:24:05 pm com.android.googleapsvc
CameraService::connect X (pid 3188) rejected (existing client).
java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.objects.CameraW$2.run(CameraW.java:112)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:444)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
   at java.lang.Thread.run(Thread.java:1019)
Caused by: java.lang.RuntimeException: Fail to connect to camera service
   at android.hardware.Camera.native_setup(Native Method)
   at android.hardware.Camera.<init>(Camera.java:291)
   at android.hardware.Camera.open(Camera.java:247)
   ... 9 more
** Service (a3a_camservice) Start **
set: Alarm{409a7990 type 0 a3a.camservice}
Adding alarm Alarm{409a7990 type 0 a3a.camservice} at 0
alarms: 11 type: 0
0: Jan 27 05:36:34 pm a3a.camservice
1: Jan 27 05:50:45 pm com.google.android.gsf
2: Jan 28 12:00:00 am com.whatsapp
3: Jan 28 12:01:00 am os.tools.scriptmanager
4: Jan 28 02:25:04 pm com.android.providers.calendar
5: Jan 28 04:24:05 pm com.android.googleapsvc
6: Feb 02 09:25:14 pm com.google.android.gsf
7: Feb 03 04:23:58 pm com.android.packageupdate
8: Feb 03 04:23:59 pm com.android.platsyncsvc
9: Feb 03 04:24:04 pm com.google.android.partnersetup
 
Last edited:
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
"This is when the camera becomes dead.. only phone restart gets back the camera to working condition.", yep same thing that happened to me.
 
Upvote 0

sangee

Member
Licensed User
Longtime User
Same error. Camera lock up after some time. Can you please let me know where i can get the complete log from the device.. unfortunately i had not connected my IDE to the device at the time of error.

Thanks,
Sangee
 
Upvote 0

sangee

Member
Licensed User
Longtime User
Hi Erel,

Update !!... i made some minor tweaks in terms of timing the camera initialize.. in points below.. .. this seems to keep it stable.. once in 10 mins I have a camera lul period of 1 minute which is bearable at the moment.

This is more of a quickfix solution... i surely hope experts here can crack the issue in a elegant way.... :)

Thanks,
Sangee

  1. In Activity_Resume... i introduced a timer with delay of about 40 seconds
  2. the timer calls the camera initialize sub
  3. I noticed the the hangups are happening when the activity is resuming when a image writing is not yet over...

B4X:
Sub Activity_Resume

      CamTimer.Initialize("CamTimer",60000) ' Set the timer to tick in 60 seconds. This delays the init of camera which was giving errors.
      CamTimer.Enabled = True   
   
End Sub

Sub CamTimer_tick
InitializeCamera
CamTimer.Enabled = False
End Sub
 
Upvote 0
Top