I've made a very simple minimal example for this to get to the bottom of the camera crash that I've reported a number of other places. Reducing it right down to this from the getting started template: package org.littlemonkey.test;
import com.codename1.capture.Capture; import static com.codename1.ui.CN.*; import com.codename1.io.Log; import com.codename1.ui.Button; import com.codename1.ui.FontImage; import com.codename1.ui.Form; import com.codename1.ui.Dialog; import com.codename1.ui.layouts.BorderLayout; import com.codename1.ui.plaf.UIManager; import com.codename1.ui.util.Resources; import com.codename1.ui.Toolbar; import java.util.ArrayList; import java.util.List; /** * This file was generated by <a href="https://www.codenameone.com/">Codename * One</a> for the purpose of building native mobile applications using Java. */ public class CaptureTest { private Form current; private Resources theme; private final List<Button> buttons = new ArrayList<>(); public void init(Object context) { theme = UIManager.initFirstTheme("/theme"); // Enable Toolbar on all Forms by default Toolbar.setGlobalToolbar(true); // Pro only feature Log.bindCrashProtection(true); } public void start() { if (current != null) { current.show(); return; } Form hi = new Form("Welcome", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER)); Button getStarted = new Button("Take a photo"); FontImage.setMaterialIcon(getStarted, FontImage.MATERIAL_CAMERA); getStarted.setUIID("GetStarted"); hi.addComponent(BorderLayout.SOUTH, getStarted); getStarted.addActionListener((e) -> { String path = Capture.capturePhoto(); }); hi.show(); } public void stop() { current = getCurrentForm(); if (current instanceof Dialog) { ((Dialog) current).dispose(); current = getCurrentForm(); } } public void destroy() { } } The relevant part it just the action listener which opens the camera and ignores the result: getStarted.addActionListener((e) -> { String path = Capture.capturePhoto(); }); On iOS around 175 photos can be taken before the app crashes back to the home screen. Changing this to this call: getStarted.addActionListener((e) -> { String path = Capture.capturePhoto(400,-1); }); The only 100 photos can be taken before the app crashes. In my more complex app that resizes images and processes them it also has a limit of around 100 calls to Capture.capturePhoto before it crashes. This is case regardless of what I do with the photo once its taken. If its ignore like above it crashes. If its processed, saves and displayed as a thumbnail it'll crash at around 100 photos. If I save and process it 100 times per photo taken I can save and thumbnail 10,000 images but only from 100 capture calls. I'm now confident that my image resizing code is memory performant and working well, but this capture call by itself is causing a leak or other issue that prevents it from being used repeatedly. These photos are not taken in quick succession or anything like that, 3 - 4 photos at a time in different rooms of a house and even over a few houses, but once ~100 capture calls have been made with the app still open then it will crash. Force quitting the app between rooms or reloading it after crash gets another 100 but clearly not an acceptable use case. I'll also file it as an issue, but wanted to put it in the discussion forum as well in case there are insights from the wider community. -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/8f17b358-0742-42f5-b7d6-9b833e91bf15%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
