codenameone / CodenameOne

Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.
https://www.codenameone.com/
Other
1.7k stars 403 forks source link

drawing outruns rendering #3388

Open ddyer0 opened 3 years ago

ddyer0 commented 3 years ago

This occurs on a relatively low performance android device. The symptom is that the app freezes and then crashes. It took some experimentation and good luck to capture this stack trace.

The drawing operation in question is doing something pretty innocuous - just drawing some single-line horizontal rectangles, but it is doing a lot of them very fast. Surely, there must be a throttle somewhere that is supposed to stall the drawing process while the host machine engine catches up?

error is : java.lang.OutOfMemoryError: Failed to allocate a 4021252 byte allocation with 2895962 free bytes and 2MB until OOM java.lang.OutOfMemoryError: Failed to allocate a 4021252 byte allocation with 2895962 free bytes and 2MB until OOM at java.util.ArrayList.add(ArrayList.java:118) at com.codename1.impl.android.AndroidAsyncView$AsyncGraphics.drawRect(AndroidAsyncView.java:2318) at com.codename1.impl.android.AndroidImplementation.drawRect(AndroidImplementation.java:2314) at com.codename1.ui.Graphics.drawRect(Graphics.java:417) at lib.Graphics.drawRect(Unknown Source) at lib.G.frameRect(Unknown Source) at lib.G.drawAASymline(Unknown Source) at lib.G.DrawAACircle(Unknown Source) at zertz.common.ZertzGameViewer.drawBlankTile(Unknown Source) at zertz.common.ZertzGameViewer.drawTile(Unknown Source) at zertz.common.ZertzGameViewer.DrawBoardElements(Unknown Source) at zertz.common.ZertzGameViewer.redrawBoard(Unknown Source) at online.game.commonCanvas.redrawClientBoard(Unknown Source) at online.game.commonCanvas.drawCanvas(Unknown Source) at online.common.exCanvas.drawClientCanvas(Unknown Source) at lib.TouchMagnifier.drawMagnifiedPad(Unknown Source) at online.common.exCanvas.drawVirtualMouse(Unknown Source) at online.common.exCanvas.paintSprites(Unknown Source) at online.game.commonCanvas.paintSprites(Unknown Source) at lib.RepaintManager.drawCanvas(Unknown Source) at lib.RepaintManager$1.run(Unknown Source) at bridge.Platform.runInEdt(Unknown Source) at lib.RepaintManager.redrawCanvas(Unknown Source)

ddyer0 commented 3 years ago

I"m wondering if it would be appropriate to expose the functionality "flushGraphics" and perhaps the size of "pendingRenderingOperations". Also, is there a prescribed way to pause in the middle of a "paint" operation (to let the hardware catch up) without choking the rest of the app?