mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

CEF browser crashes when zooming in with leaflet.js

Open bum8hj opened this issue 1 year ago • 4 comments

Describe the bug

I'm having an issue where my CEF browser crashes due to a sort of unknown reason. I'm using leaflet.js to display a map, and when I zoom in on the map, the browser crashes.

Test Resource leaflet.zip

Steps to reproduce

  1. Start the resource
  2. optional Press K to open BrowserDevTools
  3. Click the Zoom In button +

If (for whatever reason) it triggered the crash, you should notice that the browser is frozen on the last rendered frame. If you have DevTools open, you should see 'Render process gone'.

Version

v1.6-release-22388 Windows 11 (10.0.22631)

Additional context

Things I found to be irrelevant (i.e. the crash happens regardless of it)

  • Windowed Mode
  • Screen Resolution
  • Image width/height / File size

I tried all sorts of debugging methods I can and there's no doubt it's caused by a function or some calculations within leaflet.js, but specifically within MTA's CEF. Particularly calling map.fitBounds() or map.zoomIn().

  • The crash never happens on my Chrome browser, but only in MTA.
  • The crash happens "randomly" and I haven't found a pattern as to what causes it.
  • I had 3 other testers try it. One never crashed, but another did crash sometimes. (same MTA version)
  • MTA/CEF/cefdebug.txt shows nothing at the time of the crash as far as I know.

I made a test resource which has the code necessary to enable you to trigger the crash. However, since I don't know the requirements/pattern for the crash, you may have to try the reproduction steps multiple times, restart the resource, reconnect, etc.

Relevant log output

No response

Security Policy

  • [x] I have read and understood the Security Policy and this issue is not security related.

bum8hj avatar Mar 01 '24 00:03 bum8hj

I can't reproduce crash on Win 10.0.19045.2364. Latest MTA Client.

znvjder avatar Mar 01 '24 07:03 znvjder

Henlo, Ive been one of the testers and I havent had a single crash for past few days. Today I wanted to investigate more and on first loadup it just crashed. Second loading crashed as well. On third time, everything was fine, even after restarting the test resource multiple times. After the tenth try, it crashed again, so its not really consistent. Note that the crash offset stays same accross multiple runs.

This error popped up for me: Screenshot 2024-03-01 113125

Multi Theft Auto v1.6-release-22388 Nvidia RTX 3080

Looking at dxGetStatus, theres nothing suspicious going on.

Edit: After looking in taskmanager, the process rams up to ~23MB before crashing, not sure if this is problematic, it doesnt look like much used memory though.

Screenshot 2024-03-01 114437_2

ffsPLASMA avatar Mar 01 '24 10:03 ffsPLASMA

Adding console.log(any3d, webkit3d); to leaflet.js on line 2138 (after var Browser definition) returns true, true which suggests it's trying to use hardware accelerated 3D transforms. Hardware acceleration is not enabled in MTA CEF.

Can you try to add <script>L_DISABLE_3D = true;</script> before including leaflet.js in the index.html? i.e

<script>L_DISABLE_3D = true;</script>
<script src="leaflet.js"></script>

Edit: nevermind, I'm still able to replicate it after some tries. I've probably replicated the issue 3 times out of 50 attempts. Never received the crash dialog though, only the browser 'freezing'.

OS Name: Microsoft Windows 10 Pro OS Version: 10.0.19045 N/A Build 19045 Multi Theft Auto v1.6-release-22388 Nvidia RTX 3080

Lpsd avatar Mar 01 '24 17:03 Lpsd

Good news I guess, we traced down to what causes the freeze/crash.

Reference: https://github.com/Leaflet/Leaflet/issues/4821

The painting "thread" causes the CEF process to freeze/crash due to overload/timeout.

As an example: 6000x6000 JPG image: Screenshot 2024-03-04 230725

Now a 3000x3000 JPG image: Screenshot 2024-03-04 231532

This would explain the incosistency across multiple runs, depending on how long the painting takes, the CEF process may freeze/crash.

Question remains if we can fix/optimize that in a certain way? For now the solution is to take a smaller image texture.

ffsPLASMA avatar Mar 04 '24 22:03 ffsPLASMA