-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Describe the bug
In the process of upgrading my builder.io usage to use the Gen2 SDK, I updated my components to use the BuilderContent, replacing the BuilderComponent. I'm providing my apiKey, my model ("page"), and my content (using fetchOneEntry). No matter which one of my builder pages I visit, the user interaction becomes extremely sluggish. No changes were made to the content, and the Gen1 implementation does not have this problem. Pages with sidebars will be so sluggish that upon clicking the button to open the sidebar, several seconds go by before anything happens visually, and the animations are not rendered. The sidebar does not close any more with the use of Gen2.
I'm having trouble diagnosing what the issue is. I'm attempting to use DevTools to determine what code is executing to make the app feel so sluggish, but memory seems fine, and I don't get much information from the profiler that looks like lots of executions. If I click the pause button on the debugger, I don't break execution until some 30 second ping message on a websocket goes off, making me think the app is fairly idol.
And when I go to pages that don't have any builder content, I see no performance issues whatsoever. I'm just not sure how to further diagnose the issue. But all user interaction of any kind on builder content is delayed by at least several seconds if not longer. Hover over clickable elements takes seconds to show a different cursor. But I have to point out that this happens with pages that contain purely just sections of text as well, with no intractable elements. Even just a privacy policy page is causing extreme stuttering while attempting to scroll through the content. But this is only the builder.io content. On pages without builder.io content, scrolling is as smooth as would be expected.
I intend only to provide a data point as I acknowledge that Gen2 is in beta.
To Reproduce
Steps to reproduce the behavior:
- Start with Angular 19 app using Gen1 SDK
- Upgrade to using the Gen2 SDK
Expected behavior
I expect there to be no degradation in performance.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Below are examples of how I'm using the Gen2 library:
import {
ChangeDetectionStrategy,
Component,
inject,
resource,
} from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { Content, fetchOneEntry } from '@builder.io/sdk-angular';
import { environment } from '../../environments/environment';
import { EmailSubscriptionService } from '../email-subscription.service';
@Component({
selector: 'app-cms-page',
imports: [MatProgressSpinnerModule, Content],
templateUrl: './cms-page.component.html',
styleUrl: './cms-page.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CmsPageComponent {
readonly #emailSubscriptions = inject(EmailSubscriptionService);
protected readonly context = toSignal(this.#emailSubscriptions.context$);
protected readonly apiKey = environment.builder.apiKey;
protected readonly content = resource({
loader: () =>
fetchOneEntry({
apiKey: this.apiKey,
model: 'page',
userAttributes: { urlPath: window.location.pathname || '' },
}),
});
}@if (content.isLoading()) {
<mat-spinner />
} @else if (content.value()) {
<builder-content
model="page"
[content]="content.value()"
[apiKey]="apiKey"
[context]="context()"
/>
} @else if (content.error()) {
<div>{{ content.error() }}</div>
} @else {
<div>404 - Content not found</div>
}import {
ChangeDetectionStrategy,
Component,
OnChanges,
resource,
SimpleChanges,
} from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { RouterOutlet } from '@angular/router';
import { Content, fetchOneEntry } from '@builder.io/sdk-angular';
import { derivedFrom } from 'ngxtension/derived-from';
import { injectNavigationEnd } from 'ngxtension/navigation-end';
import { pipe } from 'rxjs';
import { map } from 'rxjs/operators';
import { environment } from '../environments/environment';
@Component({
selector: 'app-root',
imports: [RouterOutlet, Content],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
readonly #isLaunchPage = toSignal(
injectNavigationEnd().pipe(map((event) => event.url === '/'))
);
protected readonly apiKey = environment.builder.apiKey;
protected readonly headerContent = resource({
loader: () => fetchOneEntry({ apiKey: this.apiKey, model: 'header' }),
});
protected readonly footerContent = resource({
loader: () => fetchOneEntry({ apiKey: this.apiKey, model: 'footer' }),
});
protected readonly showHeader = derivedFrom(
[this.#isLaunchPage, this.headerContent.value],
pipe(map(([isLaunchPage, value]) => !isLaunchPage && value)),
{
initialValue: false,
}
);
protected readonly showFooter = derivedFrom(
[this.#isLaunchPage, this.footerContent.value],
pipe(map(([isLaunchPage, value]) => !isLaunchPage && value)),
{
initialValue: false,
}
);
}@if (showHeader()) {
<header>
<builder-content
model="header"
[apiKey]="apiKey"
[content]="headerContent.value()"
/>
</header>
}
<main>
<router-outlet />
</main>
@if (showFooter()) {
<footer>
<builder-content
model="footer"
[apiKey]="apiKey"
[content]="footerContent.value()"
/>
</footer>
}