Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back synced frame method and use it for triggerRepaint. #4535

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xabbu42
Copy link
Contributor

@xabbu42 xabbu42 commented Aug 10, 2024

Launch Checklist

An experimental fix for #4534. With this I can again a capture a single frame with spector.js, as all the rendering is directly done inside the requestAnimationFrame callback.

Unfortunatly tests dont run through but fail after some random point. Probably a race I introduced?

  • Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • Briefly describe the changes in this PR.
  • Link to related issues.

@xabbu42 xabbu42 mentioned this pull request Aug 10, 2024
6 tasks
@codecov-commenter
Copy link

codecov-commenter commented Aug 10, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.

Project coverage is 69.50%. Comparing base (3f28408) to head (0221865).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/ui/map.ts 80.00% 2 Missing and 1 partial ⚠️

❗ There is a different number of reports uploaded between BASE (3f28408) and HEAD (0221865). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3f28408) HEAD (0221865)
9 8
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4535       +/-   ##
===========================================
- Coverage   91.95%   69.50%   -22.45%     
===========================================
  Files         282      282               
  Lines       38908    38917        +9     
  Branches     6820     1321     -5499     
===========================================
- Hits        35777    27049     -8728     
- Misses       3003    11226     +8223     
- Partials      128      642      +514     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@HarelM
Copy link
Collaborator

HarelM commented Aug 11, 2024

requestAnimationFrame is not a method that runs right away as far as I know, it might have higher priority than a promise, but I'm not sure I saw it anywhere, so I'm not sure I know how this fix will actually solve anything, but let me know if it does.
I think the code introduced here is fine in terms of how it looks.
A test is needed to cover the relevant issue (spector.js if I understood correctly).

In case this is not ready for review, please change it to a draft and ping me when you change it back to regular PR.

THANKS!

@xabbu42 xabbu42 marked this pull request as draft August 13, 2024 09:24
@xabbu42
Copy link
Contributor Author

xabbu42 commented Aug 13, 2024

this experiment is not about the time between the call to requestAnimationFrame and when the passed callback is called, but about the time between the call to the passed callback and the actual map._render call. Currently the passed callback only schedules the _render and then returns whereas before the callback directly called _render.

Come to think of it, it should be possible to keep with the promise based interface for frameAsync for the time between the call to frameAsync and when the callback of requestAnimationFrame actually gets triggered while at the same time calling _render directly in the callback. I'll try to implement that approach.

@HarelM
Copy link
Collaborator

HarelM commented Aug 13, 2024

Can we pass down the callback to the request animation frame and then call the resolve at the end? Would that work? Or is this the scratched out part in your comment?

@HarelM HarelM mentioned this pull request Oct 28, 2024
8 tasks
@HarelM
Copy link
Collaborator

HarelM commented Jan 12, 2025

@xabbu42 what's the status of this PR?
Are you planning on marking it as ready for review or close it?

@xabbu42
Copy link
Contributor Author

xabbu42 commented Jan 21, 2025

I still plan to finish this. There are uncaught exceptions during the unit tests which I still have to look into.

Sidenote: I was lead quite astray because the exceptions from the unit tests also aborted the render tests when running npm run test so all I see in the console are a lot of render test failures.

@HarelM
Copy link
Collaborator

HarelM commented Jan 21, 2025

npm run test is running all the tests in the repo, I always run just a single part of the test using: npm run test-unit, npm run test-build, npm run test-render etc.
Also the CI runs them separately so you can see which is failing and why.

@xabbu42
Copy link
Contributor Author

xabbu42 commented Jan 21, 2025

I think the problem of the failing unit tests is more with the tests themself than a bug with this change.

This as far as I got analyzing them:

  • there are two problematic tests 'recalculate zoom is done on the camera update transform' in map_zoom.test.ts and 'getZoom on moveend is the same as after the map end moving, with terrain on' in map_events.test.ts.
  • they are unique as they both include map.terrain = createTerrain(); in the setup and then later trigger a map paint.
  • with terrain set, Painter.maybeDrawDepthAndCoords calls Painter.useProgram without forceSimpleProjection to draw something
  • Painter.useProgram without forceSimpleProjection expects this.style.projection to be set, but with the used empty style it isnt which triggers an exception

The map state produced by this tests can not happen with normal usage, as setTerrain would not work with the empty style used for tests.

Any pointers how this tests should be fixed?

@HarelM
Copy link
Collaborator

HarelM commented Jan 21, 2025

Looks like something is failing when the test harness is completing or something.
Try and use test.only to find the offeding test.
The test are failing because style.projection is not defined, so it should be mocked as part of the test.
I hope this helps, if not feel free to reach out in slack and I'll see how else I can help out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants