GSOC 2018 -- Event Recording Proposal

Iaron da Costa Araújo

New Member
Contributor
#1
Summary: This project consists of the implementation of Event Recording on Terasology, where the recorded events could be replayed in a game session. This is useful for creating benchmark tests and also regression tests. A ModuleTestingEnvironment expansion to support recorded events is also proposed.
Student: Iaron da Costa Araújo
Mentors: Cervator, eviltak, Daniel H (oniatus), J Dill
GitHub: https://github.com/orgs/MovingBlocks/projects/13
Slack: iaronaraujo
Blog: https://iaronaraujo.wixsite.com/meusite/blog/
 
Last edited:

Iaron da Costa Araújo

New Member
Contributor
#2
Weekly Report May 7th, 2018

What have you achieved in the last 2 weeks?

I've been working on making a small trial of record and replay, where some events are recorded and stored in memory to be replayed.
I learned a lot about how Events and Entities work on Terasology and made Record and Replay work for PlaySoundEvent.

What are you currently working on?

Making the Record and Replay work for the other types of events, especially InputEvents.

What problems are you currently facing?

There is a problem with Components on the replay because the events that aren't being replayed right now are the ones that need an entity to have certain types of components to be processed.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

Nothing yet.

Something else (pictures of new content, code snippets, new wiki content, …)

Nothing.
 

Iaron da Costa Araújo

New Member
Contributor
#3
I was finally able to make another event type work (JumpButton)! And while doing so, I've learned some important things about replaying the events.
To reproduce events successfully, it is essential to assure two things on the Recording process:

1 - Every Event is sent to an Entity, and it is important to save its ID for every event recorded because these Entities have the Necessary Components to make the event be selected to be processed by a System. The problem is that while some EntityRefs remain with the same ID when you reload the game, others don't. Therefore, assuring the correct Entity ID mapping for the Events to be replayed is essential.

2 - The Entity ID, its mapping to an EntityRef and the components it has is important to make a System select an Event, but that does not make the Event replay work properly. To do so, it is necessary to save a deep copy of the events being sent during the recording process, that way it is possible to have the event with the exact proprieties and states it had before it was sent by an EventSystem.
 

Iaron da Costa Araújo

New Member
Contributor
#4
Weekly Report May 11th, 2018

What have you achieved this week?

I finished the Record and Replay trial. More details of how to use it in my blog.

What are you currently working on?

The next goal should be to implement RecordedEvent serialization, so it will be possible to record events to be replayed any time.

What problems are you currently facing?

No problems for now.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

I updated the github board and moved the trial task to the "Done" column

Something else (pictures of new content, code snippets, new wiki content, …)

I was able to film the trial in execution, but the video's quality is a bit low:
https://terasology.slack.com/files/U9PFGA6EL/FAM5XU596/record_replay_small_trial.mp4
 

Iaron da Costa Araújo

New Member
Contributor
#5
Weekly Report May 18th, 2018

What have you achieved this week?

I learned more about how serialization is done in Terasology and I finished RecordedEvent serialization.

What are you currently working on?

RecordedEvent deserialization and testing it.

What problems are you currently facing?

The way I am serializing RecordedEvents is not very clean. Therefore, this needs a good refactoring later.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

None.

Something else (pictures of new content, code snippets, new wiki content, …)

The JSON with the RecordedEvents is attached to this reply
 

Attachments

Iaron da Costa Araújo

New Member
Contributor
#6
Weekly Report May 25th, 2018

What have you achieved this week?

Finished RecordedEvent serialization and updated the Trial with persistence updates. More details on my blog (https://iaronaraujo.wixsite.com/meusite/blog/trial-updated-with-persistence)

What are you currently working on?

My next goal is to implement an UI for record and replay

What problems are you currently facing?

None.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

None.

Something else (pictures of new content, code snippets, new wiki content, …)
 

Iaron da Costa Araújo

New Member
Contributor
#7
Weekly Report June 1st, 2018

What have you achieved this week?

Created Record and Replay (RR) UI, opened a PR to merge RR's first release into the develop branch. Fixed issues and improved code related to the suggestions made in the PR.

What are you currently working on?

Fixing and improving the code even more according to the PR reviews!

What problems are you currently facing?

None.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

https://github.com/MovingBlocks/Terasology/pull/3376

Something else (pictures of new content, code snippets, new wiki content, …)
 

Iaron da Costa Araújo

New Member
Contributor
#8
Weekly Report June 8th, 2018

What have you achieved this week?

Refactored the code according to the PR reviews, created a new small test for EventSystemReplayImpl, partially fixed "entity x doesn't exist" error during replays and began investigating the issue that causes a replay to not be replayed as intended.

What are you currently working on?

Fixing the replay problem in which the replays don't replay events exactly as they were recorded, leading to weird and inaccurate replays.

What problems are you currently facing?

None.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

https://github.com/MovingBlocks/Terasology/pull/3376 is still open

Something else (pictures of new content, code snippets, new wiki content, …)

I noticed that when I replayed the game without touching my mouse or keyboard, the replays were executed perfectly, with everything being replayed as intended. So then I tried to replay again, but this time moving the mouse a little when the game is loaded, and then near the ending of the replay, it messed up. Then to check again, I replayed the same recording while moving the mouse a lot and pressing the WASD and space bar button, but then, somehow, the replay this time was perfect.

Therefore, I am beginning to suspected that what may be causing the replay errors isn't lag at all, but maybe the player trying to send input events during a replay. To confirm that, I would like people to download my repository (record_replay_release or record_replay_develop branch) and then make recordings and try to replay them without touching the mouse or keyboard after you click to load a replay. After the replay is done, I would like to know if the replay was executed perfectly or not.
 
Last edited:

Iaron da Costa Araújo

New Member
Contributor
#9
Weekly Report June 15th, 2018

What have you achieved this week?

Fixed more bugs and began investigating the replay issues. Found a potential solution to the issue.

What are you currently working on?

Testing and improving the potential solution.

What problems are you currently facing?

The replay problem is a bit weird and it is hard to reproduce it, which makes testing it very time-consuming. It is also very likely that most of the things that could be causing this problem are changed by side effects, which makes it hard to trace the source of the problem.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

https://github.com/MovingBlocks/Terasology/pull/3376 is still open

Something else (pictures of new content, code snippets, new wiki content, …)
 
Last edited:

Iaron da Costa Araújo

New Member
Contributor
#10
Weekly Report June 22th, 2018

What have you achieved this week?

Greatly improved the replay issue, but it still persists to a minor degree. Found a potential issue in the ServerCharacterPredictionSystem and discussed it in the #architecture channel of slack. Fixed the issue where some events were being sent in wrong order.

What are you currently working on?

Still investigating the replay issue.

What problems are you currently facing?

Basically the same problem of last week, but I found better ways to test it.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

https://github.com/MovingBlocks/Terasology/pull/3376 is still open

Something else (pictures of new content, code snippets, new wiki content, …)
 

Iaron da Costa Araújo

New Member
Contributor
#11
Weekly Report June 30th, 2018

What have you achieved this week?

Fixed MTE since the addition of the screenshot during a save crashed its tests, fixed the issue in which holding the mouse's left button during a recording was causing the replays to not replay things correctly.

What are you currently working on?

Investigating the issue that happens when the player holds right-click during a recording, and I will probably investigate ModuleTestingEvironment to add test support to Record and Replay.


What problems are you currently facing?

The entity IDs changing when the game is causing some issues when I try to record some new event types.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

https://github.com/MovingBlocks/Terasology/pull/3376 is still open
opened https://github.com/Terasology/ModuleTestingEnvironment/pull/5

Something else (pictures of new content, code snippets, new wiki content, …)
 

Iaron da Costa Araújo

New Member
Contributor
#12
Weekly Report July 6th, 2018

What have you achieved this week?

Wrote wiki page about how to use Record & Replay (https://github.com/MovingBlocks/Terasology/wiki/How-to-Use-Record-and-Replay), created a new PR that fixes the left click issue with Record & Replay, implemented some basic test support for replays (https://github.com/iaronaraujo/Terasology/tree/replay_test_dev)

What are you currently working on?

Improving test support for replays. The next goal is to make a replay open instead of the main menu.


What problems are you currently facing?

None.

Is anything blocking you from making progress?

Not yet, but it is possible that I will need the PR 3403 soon.

List of PRs and opened/closed Issues

closed https://github.com/MovingBlocks/Terasology/pull/3376
closed https://github.com/Terasology/ModuleTestingEnvironment/pull/5
opened https://github.com/MovingBlocks/Terasology/pull/3416

Something else (pictures of new content, code snippets, new wiki content, …)
 

Iaron da Costa Araújo

New Member
Contributor
#13
Weekly Report July 13th, 2018

What have you achieved this week?

Implemented test support for Record & Replays with the creation of Replay Tests. There is also a new wiki page about it.

What are you currently working on?

Trying to fix the problem in which selecting to run more than one Replay test causes issue in the second test. If the PR 3403 gets merged, this should be dropped in favor of working into improving the serialization.


What problems are you currently facing?

It is hard to track the source of this problem since the replay tests initialize a game, which makes debugging it very tiresome.

Is anything blocking you from making progress?

Working on the Recorded Events serialization should be my priority now, but to work on that I need PR 3403 to be merged.

List of PRs and opened/closed Issues

https://github.com/MovingBlocks/Terasology/pull/3416 is still open.

Something else (pictures of new content, code snippets, new wiki content, …)
 
#14
Weekly Report July 20th, 2018

What have you achieved this week?

Overall refactor of Record and Replay, updated the TestReplayModule and began investigating how to run Replay Tests on a headless engine.

What are you currently working on?

Trying to make Replay Tests work on a headless engine.

What problems are you currently facing?

Most of the existing content for headless engine seems to be outdated, which may leave me without many examples to base my work on.

Is anything blocking you from making progress?

No.

List of PRs and opened/closed Issues

closed https://github.com/MovingBlocks/Terasology/pull/3416.
opened https://github.com/MovingBlocks/Terasology/pull/3438
opened https://github.com/MovingBlocks/Terasology/pull/3442
opened https://github.com/MovingBlocks/Terasology/pull/3443
new module https://github.com/Terasology/TestReplayModule

Something else (pictures of new content, code snippets, new wiki content, …)

We decided to forget about improving how serialization is done for now since that will need a major change on how Terasology handles serialization.