Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
107 stars 83 forks source link

Building with r368 causes rapid crash on mobile following Android export when Viewport fit is set to "Cover" #7566

Closed dxt-ucl closed 11 months ago

dxt-ucl commented 11 months ago

Projects built and exported to android studio cause rapid and inevitable crash on android devices within ~20s of game starting. Memory use on mobile rapidly ramps up to 8GB (primarily graphics), and then the app gets killed by android.

image

I can reproduce by creating fresh projects, add any moving sprite onto the screen (e.g. in the attached example is just a simple sprite with sine behaviour on so that it's moving. The sine isn't necessary for the bug, but it seems to need objects to be moving on the screen. Any kind of movement seems to trigger it). I can currently only test on a Samsung S21 Ultra. Viewport fit needs to be set to "cover".

TestAndroidExport.zip

Steps to reproduce

  1. Export the project as an Android Studio Project.
  2. Open in Android studio, plug in a phone via USB and run it via android studio, or export as an APK and install then run it.
  3. I have only tested on a samsung S21 ultra.

Observed result

Without fail the app crashes within ~20s of launch. The exact same c3p built using v358 does not crash. There seems to be some kind of memory leak, or the app just keeps adding all on-screen graphics to memory every second, because if there are no moving objects on the screen it does not occur. If there is a controllable moving object on the screen (e.g. a box with drag and drop enabled), then the memory ramps up while that object is moving, and stops when it is not moving. However no memory seems to ever be released, so a crash is inevitable.

Expected result

The app not to crash.

More details

Affected browsers/platforms: Android. There is not issue at all when running the same apps through construct in the browser, or even remote preview on the same phone.

First affected release: Started in r368. Exact same apps built using r358 had no issues at all.

System details

View details Platform information Product: Construct 3 r368 (stable) Browser: Edge 119.0.2151.72 Browser engine: Chromium Context: browser Operating system: Windows 11 Device type: desktop Device pixel ratio: 0.800000011920929 Logical CPU cores: 16 Approx. device memory: 8 GB User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0 Language setting: en-US Local storage Storage quota (approx): 558 gb Storage usage (approx): 115 mb (0%) Persistant storage: No Browser support notes This list contains missing features that are not required, but could improve performance or user experience if supported. Nothing is missing. Everything is OK! WebGL information Version string: WebGL 2.0 (OpenGL ES 3.0 Chromium) Numeric version: 2 Supports NPOT textures: yes Supports GPU profiling: no Supports highp precision: yes Vendor: Google Inc. (AMD) Renderer: ANGLE (AMD, AMD Radeon(TM) Graphics (0x00001681) Direct3D11 vs_5_0 ps_5_0, D3D11) Major performance caveat: no Maximum texture size: 16384 Point size range: 1 to 1024 Extensions: EXT_color_buffer_float EXT_color_buffer_half_float EXT_disjoint_timer_query_webgl2 EXT_float_blend EXT_texture_compression_bptc EXT_texture_compression_rgtc EXT_texture_filter_anisotropic EXT_texture_norm16 KHR_parallel_shader_compile OES_draw_buffers_indexed OES_texture_float_linear OVR_multiview2 WEBGL_clip_cull_distance WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_lose_context WEBGL_multi_draw WEBGL_provoking_vertex Audio information System sample rate: 48000 Hz Output channels: 2 Output interpretation: speakers Supported decode formats: WebM Opus (audio/webm; codecs=opus) Ogg Opus (audio/ogg; codecs=opus) WebM Vorbis (audio/webm; codecs=vorbis) Ogg Vorbis (audio/ogg; codecs=vorbis) MPEG-4 AAC (audio/mp4; codecs=mp4a.40.5) MP3 (audio/mpeg) FLAC (audio/flac) PCM WAV (audio/wav; codecs=1) Supported encode formats: WebM Opus (audio/webm; codecs=opus) Video information Supported decode formats: WebM AV1 (video/webm; codecs=av01.0.00M.08) MP4 AV1 (video/mp4; codecs=av01.0.00M.08) WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8) H.265 (video/mp4; codecs=hev1.1.2.L93.B0) H.264 (video/mp4; codecs=avc1.42E01E) Supported encode formats: WebM AV1 (video/webm; codecs=av1) WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8)
SalmanShhh commented 11 months ago

I've had a similar issue since r364 to the latest stable.

can't figure out the root cause , but seems to happen when its fullscreen-ed and with the fullscreen quality set to low for me.

Edit: forgot to mention it seems to also happen once I switch to landscape orientation on my test devices while fullscreen

KabutoJRM commented 11 months ago

The same thing happens to me since yesterday also with the viewport in "FIT", I'm going to try in "COVER" but from what you report it also fails.

AshleyScirra commented 11 months ago

I can reproduce this, and I tracked it down to solely the call to entering immersive fullscreen mode, which is activated with viewport fit cover, or when using the "hide status bar" setting. We haven't changed anything relating to this for a couple of years I think. So it's strange and seems unlikely it's related to Construct. I suspect that a recent WebView update introduced a regression, so I filed an issue with Google about that here: https://bugs.chromium.org/p/chromium/issues/detail?id=1504795 Closing this issue as it will be followed up there.

KabutoJRM commented 11 months ago

Hi Ashley, I don't use Chrome to work and compile, I use EDGE and since yesterday when I updated to 368 I can't test my APK's.

dxt-ucl commented 11 months ago

Thanks @AshleyScirra , do you have any experience submitting these types of reports in terms of what timelines we might expect for a fix? Do you think we're looking at Days / Weeks / Months ?

SalmanShhh commented 11 months ago

I can reproduce this, and I tracked it down to solely the call to entering immersive fullscreen mode, which is activated with viewport fit cover, or when using the "hide status bar" setting. We haven't changed anything relating to this for a couple of years I think. So it's strange and seems unlikely it's related to Construct. I suspect that a recent WebView update introduced a regression, so I filed an issue with Google about that here: https://bugs.chromium.org/p/chromium/issues/detail?id=1504795 Closing this issue as it will be followed up there.

I'd be surprised if it's solely related to that , when that issue doesn't happen in r363 and below? Just wanted to give my two cents

zakkaplay commented 11 months ago

@AshleyScirra I agree with @SalmanShhh I made a build with r358 and it works but r368 crashes as per the report.

dxt-ucl commented 11 months ago

Is there any way to access r358 now? Performing a build with r358 now seems the simplest way to check if it's an external vs internal issue?

zakkaplay commented 11 months ago

@dxt-ucl Sure. The releases are here :) https://www.construct.net/en/make-games/releases

dxt-ucl commented 11 months ago

@AshleyScirra just to confirm what @zakkaplay found, all my .c3p still work perfectly if I build using r358, including if I recreate the c3p in the bug report. Might suggest it is something that's changed between 358 and 368 rather than anything at the chromium end?

fredriksthlm commented 11 months ago

I would not bother to dig into any of this super old stuff regarding hiding status bar programmatically. The way Construct set immersive mode has not been supported for years by Cordova, and now not even by Google. Thats why Cordova deprecated the fullscreen plugin, since it is now totally obsolete. You should just set the fullscreen mode in config, and immersive mode in the theme . WindowManager.LayoutParams.FLAG_FULLSCREEN is deprecated since Android R (11) btw.

Personally I just create a proper theme

AshleyScirra commented 11 months ago

It is still possible that Construct's code is all correct but a change exposed a bug in some other software. So the fact an issue began with a Construct update is not yet proof that the Construct update caused the problem. In this case it is a very strange issue that seems to be related to Android WebView so I've started with an issue filed there.

If someone can identify the specific Construct release where the issue started (i.e. the specific beta release and not a range of releases), that may help with the investigation, but as above I can't promise that will lead to a quicker fix.

AshleyScirra commented 11 months ago

Coincidentally another issue was filed at #7578 regarding a GPU memory leak, which had a much simpler reproduction project (and in fact reproduced on Windows). I believe that is actually the same issue as described here. The confusion is that the problem is not actually caused by the viewport fit "cover" setting, but by coincidence the GPU memory leak is only triggered in that mode (because it depends on the viewport size, and it's merely that the viewport size is different in "cover" mode). I will ask Google to close the issue I filed as I don't think it's related to Android WebView any more. We'll have a stable patch out shortly which hopefully fixes this in all cases.