wasabia / flutter_gl

cross-platform call OpenGL API by Dart through dart:ffi. Provides OpenGL with Texture Widget on Flutter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can't render properly in release apk

leoxupku opened this issue · comments

both in running the example flutter project in this repo and my own app based on three_dart, release apk can't get proper display. have you ever try build release apk like "flutter build apk --split-per-abi".

Here are the stack infos:

--------- beginning of crash
--------- beginning of system
--------- beginning of main
12-07 02:03:28.774 21654 21684 E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception:  flutter_gl OpenGLContextES.dart toPointer _GrowableList<double> TODO 
12-07 02:03:28.774 21654 21684 E flutter : #0      toPointer (package:flutter_gl/openGL/opengl/OpenGLContextES.dart:928)
12-07 02:03:28.774 21654 21684 E flutter : #1      OpenGLContextES.uniform3fvNormal (package:flutter_gl/openGL/opengl/OpenGLContextES.dart:778)
12-07 02:03:28.774 21654 21684 E flutter : #2      OpenGLContextES.uniform3fv (package:flutter_gl/openGL/opengl/OpenGLContextES.dart:772)
12-07 02:03:28.774 21654 21684 E flutter : #3      WebGLUniformsHelper.setValueV3f (package:three_dart/three3d/renderers/webgl/WebGLUniformsHelper.dart:493)
12-07 02:03:28.774 21654 21684 E flutter : #4      WebGLUniforms.upload (package:three_dart/three3d/renderers/webgl/WebGLUniforms.dart:120)
12-07 02:03:28.774 21654 21684 E flutter : #5      WebGLRenderer.setProgram (package:three_dart/three3d/renderers/WebGLRenderer.dart:1564)
12-07 02:03:28.774 21654 21684 E flutter : #6      WebGLRenderer.renderBufferDirect (package:three_dart/three3d/renderers/WebGLRenderer.dart:568)
12-07 02:03:28.774 21654 21684 E flutter : #7      WebGLRenderer.renderObject (package:three_dart/three3d/renderers/WebGLRenderer.dart:1120)
12-07 02:03:28.774 21654 21684 E flutter : #8      WebGLRenderer.renderObjects (package:three_dart/three3d/renderers/WebGLRenderer.dart:1068)
12-07 02:03:28.774 21654 21684 E flutter : #9      WebGLRenderer.render (package:three_dart/three3d/renderers/WebGLRenderer.dart:819)
12-07 02:03:28.774 21654 21684 E flutter : #10     _ThreeJsScreenState.render (package:try_on_cloth/three_screen.dart:161)
12-07 02:03:28.774 21654 21684 E flutter : #11     _ThreeJsScreenState.animate (package:try_on_cloth/three_screen.dart:152)
12-07 02:03:28.774 21654 21684 E flutter : #12     _ThreeJsScreenState.initPlatformState.<anonymous closure> (package:try_on_cloth/three_screen.dart:92)
12-07 02:03:28.774 21654 21684 E flutter : <asynchronous suspension>
12-07 02:03:28.774 21654 21684 E flutter : 
12-07 02:06:41.657 22048 22078 E flutter : [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception:  flutter_gl OpenGLContextES.dart toPointer _GrowableList<double> TODO 

I found the issule, the type is "_GrowableList", not "List". However when I fixed it, it comes up with another problem. I get white screen. Below is the flutter log for flutter_gl.

12-07 03:32:51.896 508 568 I flutter : device pixel ratio is 3.5
12-07 03:32:51.896 508 568 I flutter : width is 411.42857142857144, height is 898.2857142857143
12-07 03:32:52.025 508 568 I flutter : OpenGLContextES
12-07 03:32:52.025 508 568 I flutter : {gl: Instance of 'LibOpenGLES'}
12-07 03:32:52.026 508 568 I flutter : OpenGLES getExtension key: EXT_color_buffer_float _v: Pointer: address=0xb9a5e400
12-07 03:32:52.027 508 568 I flutter : WebGLState..................init...........
12-07 03:32:52.027 508 568 I flutter : WebGLState. getParameter _data: 0
12-07 03:32:52.100 508 568 I flutter : THREE.WebGLProgram: gl.getProgramInfoLog() programLog: null vertexLog: null fragmentLog: null
12-07 03:35:03.371 811 840 I flutter : device pixel ratio is 3.5
12-07 03:35:03.371 811 840 I flutter : width is 411.42857142857144, height is 898.2857142857143
12-07 03:35:03.499 811 840 I flutter : OpenGLContextES
12-07 03:35:03.499 811 840 I flutter : {gl: Instance of 'LibOpenGLES'}
12-07 03:35:03.499 811 840 I flutter : OpenGLES getExtension key: EXT_color_buffer_float _v: Pointer: address=0xb9fa3800
12-07 03:35:03.501 811 840 I flutter : WebGLState..................init...........
12-07 03:35:03.501 811 840 I flutter : WebGLState. getParameter _data: 0
12-07 03:35:03.558 811 840 I flutter : THREE.WebGLProgram: gl.getProgramInfoLog() programLog: null vertexLog: null fragmentLog: null
12-07 03:37:08.844 1035 1131 I flutter : device pixel ratio is 3.5
12-07 03:37:08.844 1035 1131 I flutter : width is 411.42857142857144, height is 898.2857142857143
12-07 03:37:08.972 1035 1131 I flutter : OpenGLContextES
12-07 03:37:08.972 1035 1131 I flutter : {gl: Instance of 'LibOpenGLES'}
12-07 03:37:08.973 1035 1131 I flutter : OpenGLES getExtension key: EXT_color_buffer_float _v: Pointer: address=0xba0ce800
12-07 03:37:08.974 1035 1131 I flutter : WebGLState..................init...........
12-07 03:37:08.974 1035 1131 I flutter : WebGLState. getParameter _data: 0
12-07 03:37:09.033 1035 1131 I flutter : THREE.WebGLProgram: gl.getProgramInfoLog() programLog: null vertexLog: null fragmentLog: null

it seems the initialization of gles meet some problems and retry for many times.

  1. maybe dart has some problem on list runtimeType
    flutter/flutter#94781

2.i can not reproduce this error. this is three_dart example project?

it is too nice of you to answer my problem. I have fixed List runtimeType bug by myself. but I still meet another problem. I upload my project in github. the address is below: https://github.com/leoxupku/try_on_cloth

飞书20211207-224045
at the leftside is the wrong result from the release app, just white screen. at the rightside is the right result from the debug app, just show a rotated cylinder in the background.

link miss

maybe you can try three_dart example project

I try the three_dart project. it works perfectly which means this issue should be closed. the problem must came from some wrong setting or wrong using. I will check it by myself and sync result here. when I build the example project in three_dart, there are two problems I want to share with you. one is the "override dependencies" in pubsepc.yaml shouldn't be uploaded to the remote repository. It all depends on your local working directory. the other is I get trapped into the compiling error caused by "FlutterGlPlugin(width.toInt(), height.toInt())". this function needs two args, but provide with none. this compiling problems may caused by dart version/ flutter version. I think it may be just a warning at your environment.

I checked the example project in flutter_gl, it do reproduce the bug. release apk show nothing but debug apk work properly. I think it may causing by some project wrong settings. can you reproduce the bug in the example project in your flutter_gl repo? @wasabia

@leoxupku
flutter_gl example work for me on release mode
maybe you need check android studio error log when run release mode

I think I found the solution. release app can't display normally because it start too quickly. so MediaQuery.of(context).size return a wrong value (0, 0). I think you may change the display window size to a fixed size or add a timer to trigger the initialization.
flutter/flutter#25827