Problem/Motivation
The AMP service initialization is extremely slow, there is a ton of stuff happening in the lullabot library just when constructing it.
Would be nice to look into improving that too, but actually what I noticed is that it gets called on every request, not just AMP.
Proposed resolution
Move the initilization in AmpHtmlResponseMarkupProcessor (which is invoked on every request) from the constructor to the method where it is needed.
Another approach would be to make the whole service definition lazy because AmpHtmlResponseSubscriber only calls it on amp pages. But even then, the setting might be disabled, so that should then be moved out to the response subscriber.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
dawehnerCan we ensure to just initialize it once? This method (processMarkupToAmp) might be called multiple times.
Comment #3
berdirAs we discussed, the constructor of that object has its own singleton, so not really that important. And other places in the code call it too, so I think if we want to ensure a single object, then in that method.
Comment #4
dawehnerThis is certainly a valid bugfix!
Comment #6
mtiftGood catch! Committed and pushed to 8.x-1.x. Thanks, guys.