GithubHelp home page GithubHelp logo

Comments (12)

tpreusse avatar tpreusse commented on August 15, 2024 1

Yep, happy to work on this. Thanks for the pointers. I can't promise anything time wise, heading out for vacations mid next week. I'll post here once I'm actively working on it and making progress.

from facebook-political-ads.

thejefflarson avatar thejefflarson commented on August 15, 2024 1

I've pushed a hotfix here: 69d8324

@jeremybmerrill pointed out that we weren't successfully cleaning up all of the observers. Still, I'd love to rework parser.js into something more sane. I'm going to keep this open as a tracking issue.

from facebook-political-ads.

thejefflarson avatar thejefflarson commented on August 15, 2024

Yep, this is a hard problem right now because of how the parser is written. I think it arises here:
https://github.com/propublica/facebook-political-ads/blob/master/extension/src/parser.js#L221
Which was my way of figuring out how to grab the ad endpoint from facebook's popup. I'd love it if you could take a little time to see if we can scope that selector better so as not to pick up so many changes.

I also think we need to decouple all of the promises in that file so we can test individual functions, which will help with identifying the performance issues/

As far as the chrome thing, I think it has to do with localStorage, and I try and limit the amount of ads we store there to 100, but it still seems too much:
https://github.com/propublica/facebook-political-ads/blob/master/extension/src/utils.js#L50

We could drop it to 20, because it isn't all that important to store all the ads.

Does this sound like something you could help out with?

from facebook-political-ads.

thejefflarson avatar thejefflarson commented on August 15, 2024

FYI, I'm currently working through a large refactor to make it easier to test the extension, so hold off for now. I'll have something to show tomorrowish.

from facebook-political-ads.

jeremybmerrill avatar jeremybmerrill commented on August 15, 2024

Ha, cool. I had just started looking into the slowness of the popup, but I'll hold off.

Found this, but am not sure it's our problem. https://stackoverflow.com/questions/26276815/my-chrome-extension-popup-opens-after-a-few-seconds-its-slow-compared-to-other

from facebook-political-ads.

thejefflarson avatar thejefflarson commented on August 15, 2024

this is worth a shot in the meantime: https://stackoverflow.com/a/30164224

from facebook-political-ads.

jeremybmerrill avatar jeremybmerrill commented on August 15, 2024

Yep, that's what I'm gonna try. I guess the idea is that it fools Chrome into leaving the extension running.

from facebook-political-ads.

thejefflarson avatar thejefflarson commented on August 15, 2024

from facebook-political-ads.

jeremybmerrill avatar jeremybmerrill commented on August 15, 2024

I'm gonna give it a try. Computers do dumb things sometimes.

from facebook-political-ads.

jeremybmerrill avatar jeremybmerrill commented on August 15, 2024

It may be worthwhile to get a lighter version of things rendered, then go get ads from teh server, etc. so something happens right away when you click (even if it's just a loading spinner). Excited to see your refactor.

from facebook-political-ads.

thejefflarson avatar thejefflarson commented on August 15, 2024

from facebook-political-ads.

jeremybmerrill avatar jeremybmerrill commented on August 15, 2024
        var ls_start_time = new Date();
        persistedState = deserialize(localStorage.getItem(key));
        finalInitialState = merge(initialState, persistedState);
        console.log("loaded state from localStorage in ", new Date() - ls_start_time);

It's consistently taking -- on a fresh start of Chrome -- less than 20ms to read from localStorage, usually 4-8ms. With 20 ads stored in there. I don't think localStorage is the problem.

It does take about 150ms to get to the point where it's requesting ads from the server. While that's kind of a lot, impressionistically, the delay is more like 5 seconds.

from facebook-political-ads.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.