Groupdocs Viewer 8.0.7 - Wrong page no displayed initially during server delays to return pages

Hi, We recently moved to 8.0.7 viewer, so far its working fine. Just observed following random problem.
Issue
Wrong page no is displayed initially when the document is opened in viewer. Issue is observed when our web server is doing too much and it returns the result to /get-pages api call slowly.

e.g. when document is opened, it shows 31 page no initially and on every subsequent refresh or opening of the document it shows same 31 page no. In viewer actually by default first page is shown.
This gives misinterpretation to user as he see page no 1 but it’s shown 31.
On scroll page no is reset to what we see, so it works normal there after.

To reproduce the issue, please refer following program.cs file i have.
(Note - explicit delay introduced by using middleware for “viewer-api/get-page” so you could reproduce)

using GroupDocs.Viewer.UI.Core.Configuration;

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddGroupDocsViewerUI(options =>
    {
        options.EnableFileName = false;
        options.EnablePresentation = false;
        options.EnableHeader = false;
        options.EnableFileBrowser = true;
        options.EnableDownloadPdf = false;
        options.EnableSearch = false;
        options.EnableLanguageSelector = false;
        options.EnableFileUpload = false;
        options.PreloadPages = 300;
        options.StaticContentMode = false;
        options.EnablePrint = true;
        options.RenderingMode = RenderingMode.Image;
    });

builder.Services.AddControllersWithViews()
    .AddRazorRuntimeCompilation()
    .AddGroupDocsViewerSelfHostApi(options =>
    {
        options.SetViewerType(GroupDocs.Viewer.UI.Core.ViewerType.Jpg);
        options.SetLicensePath("GroupDocs.Viewer.lic");
    })
    .AddLocalStorage("./Files")
    .AddLocalCache("./Cache");

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
}
app.UseHttpsRedirection();

app.UseStaticFiles();

app.Use(async (context, next) =>
{
    if (context.Request.Path.ToString().Contains("viewer-api/get-page"))
    {
        await Task.Delay(1500);
    }
    await next(context);
});

app.UseRouting()
    .UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
        endpoints.MapGroupDocsViewerUI(options =>
        {
            options.UIPath = "/viewer";
            options.ApiEndpoint = "/viewer-api";
        });

        endpoints.MapGroupDocsViewerApi(options =>
        {
            options.ApiPath = "/viewer-api";
        });
    });

app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

Once you open the document, just refresh again and see if you have the page no 31 appears in browser. Use any file sufficiently large with more than 100 pages.
Could be some page no initialization logic runs early before all pages are loaded from backend over get-page call.

see image produced this problem. on multiple refresh it only shows the same page no initially.
image.jpg (190.6 KB)

Packages in csproj file

		<PackageReference Include="GroupDocs.Viewer.UI" Version="8.0.7" />
		<PackageReference Include="GroupDocs.Viewer.UI.Api.Local.Cache" Version="8.0.7" />
		<PackageReference Include="GroupDocs.Viewer.UI.SelfHost.Api" Version="8.0.7" />
		<PackageReference Include="GroupDocs.Viewer.UI.Api.AzureBlob.Storage" Version="8.0.7" />
		<PackageReference Include="GroupDocs.Viewer.UI.Api.Local.Storage" Version="8.0.7" />

Hi @vladimir.litvinchik fyi…
here is the issue observed recently. please could you have a look? could be a simple fix. Thanks.

@sachinerande

Thank you for reporting this issue. When testing the latest changes of the UI on a dev environment I have observed similar behavior. In my case it was stuck at page 18 while I was on page 1.

We’ll analyze this issue and update you.

1 Like

Great ! would be really great if can be sorted quickly. Thank you @vladimir.litvinchik,

@sachinerande

You are welcome! As soon as we get this issue fixed we’ll let you know.

1 Like

@sachinerande

We have fixed this issue in the latest version of GroupDocs.Viewer.UI package version 8.1.1. See complete list of changes in this release at Release 8.1.1 · groupdocs-viewer/GroupDocs.Viewer-for-.NET-UI · GitHub.

To get the latest version you have to update you package references and set version to 8.1.1 in your csproj file.

1 Like

Thank you @vladimir.litvinchik for fixing this, will run it through test cycle, and let you know.

1 Like

@vladimir.litvinchik Just did a quick tests and it appears following things are not working as expected on 8.1.1.

Issue 1 - workaround given on link is not working. i had to replace like below, to let it work.
string basePath = $"/{apiMethodName.TrimStart('/')}";
with
string basePath = $"/viewer-api/{apiMethodName.TrimStart('/')}";
frontend doesn’t appear to supply the custom api endpoint “viewer-api” like it did in 8.0.7 while making get-page call.

Issue 2 - This is about broken print functionality.

  1. In the above code given set the options.PreloadPages = 2;
  2. Run the solution, and opened doc in viewer with 155 pages. (you may open any lower say around 10 pages, though i didnt check)
  3. From the thumbnail scroll and click on page no. 5
  4. let the page page 5 and 6 to load. Click on Print button. The print window is stuck like shown in image and javascript error popsup in the console. see the image below.

image.png (156.9 KB)

Issue 3 - The numbers on print window doesn’t change as were before. To reproduce follow steps below.

  1. Open any document with preload page count as 2.
  2. Once document is opened just click on print button. Wait for sometime and notice the number 2 “Loaded 2 out of 250 pages” keeps there. It doesn’t change. Its expected to increment as the pages gets loaded.
    It was incrementing before on the 8.0.7 viewer.

Issue 4 - Viewer has now animation around when scrolling across pages. When say i am on page no. 1 and i go to page no. 300, there is redundant scrolling effect, is that possible to disable that with some settings ? This is not a blocker but wanted to highlight, to make it configurable.

@sachinerande

Thank you for sharing you findings. It looks like not all the changes were properly merged. We’ll review all the issues and update you.

Great, thanks @vladimir.litvinchik , I will await next fix.

1 Like