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

Android progress indication and refactor of progress logic #10

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

filip131311
Copy link
Collaborator

@filip131311 filip131311 commented Mar 19, 2024

Before:
There was no indication about the progress of android build.

Now:
Progress indicator based on number of tasks that were completed, and information about task graph.

Screen.Recording.2024-03-11.at.16.10.38.mov

Solution:
To achieve this effect I parse logs from build process to check if new tasks are being completed;
to know how many there is I added a gradle init script that logs that information.

Additionally:
This PR lets you define to which stage stageProgressListener belongs.

Copy link

vercel bot commented Mar 19, 2024

Someone is attempting to deploy this pull request to the software-mansion Team on Vercel.

To accomplish this, the commit author's email address needs to be associated with a GitHub account.

Learn more about how to change the commit author information.

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seem to be overly complex as to what we are trying to achieve. The only thing we wanted if I understand this correctly, was for the progress listener not to trigger projectstate update in case we are not at the stage the listener belongs to. IMO this should only require a few lines of changes in project.ts to inject stage information into the listener and then to compare the current stage in that listener prior to updating project state.

private completedTasks: number = 0;
private tasksToComplete: number = 0;

constructor(private progressListener: (newProgress: number, stage: number) => void) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another example of abstraction leak. The build now needs to understand the concept of stages and that it is a part of one of the stages in order to call this callback.

This seems unnecessary however, because the called that calls build stage knows about the stages and can inject stage number into the listener it provides for the build stage.

this.updateProjectState({
status: "starting",
stage: Stages.findIndex((item) => item.name === "Restarting"),
stageProgress: new Array(Stages.length).fill(0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't seem correct that we send progress for all stages here, we dont need this information on the frontend

const waitForMetro = this.metro.start(
forceCleanBuild,
(newStageProgress: number, stage: number) => {
this.stageProgressListener(newStageProgress, stage);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to have the arrow function pass listener here because we know which stage we are at, so we should call this.stageProgressListsner(newStageProgress, BUNDLE_STAGE)

public async stageProgressListener(newStageProgress: number) {
if (newStageProgress < this.projectState.stageProgress) {
public async stageProgressListener(newStageProgress: number, stage: number) {
if (newStageProgress < this.projectState.stageProgress[stage]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems overly complicated, we don't need an array of progress here.

@filip131311 filip131311 force-pushed the @Filip131311/AndroidProgressIndication branch from 8b0b14d to 0034ccd Compare March 20, 2024 23:08
@filip131311 filip131311 merged commit 86e312c into main Mar 21, 2024
1 of 2 checks passed
@filip131311 filip131311 deleted the @Filip131311/AndroidProgressIndication branch May 10, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants