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

Replace function calls in template expressions to increase performance #991

Open
IndianaDschones opened this issue May 25, 2020 · 4 comments
Labels
optimization Optimises existing functionality performance Impacts performance

Comments

@IndianaDschones
Copy link
Contributor

Bug Description

Threema Web makes massive use of function calls from template expressions like ng-src="{{ ctrl.getAvatarUri() }}". Even if it works and in this example the user avatar is shown, AngularJS worries about each function. Why? The framework needs to check several times (each digest cycle) if a new value is available. This means, that every time something changes (or may have), the function gets called. That can be veeeeeery often.

Steps to Reproduce (for bugs)

  1. Add a log statement to this.getAvatarUri in avatar.ts
  2. Launch the devserver and type a message, move the mouse or similar stuff
  3. Watch the console and the massive amount of your log message

This is just one template expression function. All the functions combined may be a reason why Threema Web is not as fast and snappy as it could be.

Potential Solution

For some functions the easy solution may be to just get the value once e.g. by initializing a variable once. But this is not a solution for avatars. The downside is, that a changed avatar would not be updated in Threema Web. So the whole process of replacing these calls may be (very) time consuming. The avatar for example may need some kind of observer pattern or push instad of this pull strategy.

More information on this topic can be found here:

Your Environment

Not important for this issue.

@IndianaDschones IndianaDschones added awaiting triage Should be triaged by a developer. bug It's a bug! labels May 25, 2020
@dbrgn dbrgn added optimization Optimises existing functionality performance Impacts performance and removed awaiting triage Should be triaged by a developer. bug It's a bug! labels May 26, 2020
@dbrgn
Copy link
Contributor

dbrgn commented May 26, 2020

Yep, this is definitely one of the reasons why the UI tends to be laggy sometimes (especially on older devices). We've done some optimization work in the past (e.g. #567), but there's surely still more potential for optimization.

However, AngularJS 1 architecture itself (especially its "check everything" digest loop) is also a big reason why optimizing is hard. In the long run we need to replace the entire codebase. We are already working on that (but I cannot give you any more details on that so far, unfortunately).

@IndianaDschones
Copy link
Contributor Author

Since you may be in an early stage: it would definitively be nice to choose/build a solution which enables the user to run Threema Web as an application (maybe Threema Desktop?). Just like Microsoft Teams, Discord and so on which can be run in a browser or as a desktop application. Imho it is more pleasant to use a dedicated application rather than opening a browser. One advantage would be to put the app in autostart.

@dbrgn
Copy link
Contributor

dbrgn commented Jun 15, 2020

That may be one of our goals 😉

@lgrahl
Copy link
Contributor

lgrahl commented Jun 16, 2020

Yeah, and maybe I already hate Electron, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Optimises existing functionality performance Impacts performance
Development

No branches or pull requests

3 participants