Skip to content

Commit

Permalink
Seeing 5 windows opened, even though only tapped on 3 model links fro…
Browse files Browse the repository at this point in the history
…m Safari

https://bugs.webkit.org/show_bug.cgi?id=261232
rdar://114172309

Reviewed by Mike Wyrzykowski.

On iOS the AR Quick Look feature is modal, which means only one preview
is open at a time. On visionOS the preview opens in a separate app, allowing
for the case where the user can tap many times and multiple windows open.
Furthermore, the communication with the system is a bit limited, which
can create a situation where more windows open than the user requested.

Limit this so that only one Quick Look can be downloading at a time. This
will still allow the user to open multiple models, but not get into this
confusing situation.

It isn't a great fix. A future change would be to keep a list of
active previews, with an upper limit, so that the user isn't blocked
from opening another file while a large file is being downloaded.

* Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
* Source/WebKit/UIProcess/SystemPreviewController.h:

Canonical link: https://commits.webkit.org/267708@main
  • Loading branch information
grorg committed Sep 7, 2023
1 parent 3aeb226 commit 8c3dd61
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 10 additions & 5 deletions Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ - (void)completeLoad

void SystemPreviewController::begin(const URL& url, const SecurityOriginData& topOrigin, const WebCore::SystemPreviewInfo& systemPreviewInfo, CompletionHandler<void()>&& completionHandler)
{
if (m_state != State::Initial) {
RELEASE_LOG(SystemPreview, "SystemPreview didn't start because an existing preview is in progress");
return completionHandler();
}

ASSERT(!m_qlPreviewController);
if (m_qlPreviewController)
return completionHandler();
Expand Down Expand Up @@ -409,7 +414,7 @@ - (void)completeLoad
[presentingViewController presentViewController:m_qlPreviewController.get() animated:YES completion:nullptr];
#endif

m_state = State::Began;
m_state = State::Initial;
}

void SystemPreviewController::loadStarted(const URL& localFileURL)
Expand Down Expand Up @@ -438,16 +443,16 @@ - (void)completeLoad
#if PLATFORM(VISION)
if ([getASVLaunchPreviewClass() respondsToSelector:@selector(launchPreviewApplicationWithURLs:completion:)])
[getASVLaunchPreviewClass() launchPreviewApplicationWithURLs:localFileURLs() completion:^(NSError *error) { }];
m_state = State::Initial;
#else
if (m_qlPreviewControllerDataSource)
[m_qlPreviewControllerDataSource finish:m_localFileURL];
m_state = State::Viewing;
#endif
releaseActivityTokenIfNecessary();

if (m_testingCallback)
m_testingCallback(true);

m_state = State::Succeeded;
}

void SystemPreviewController::loadFailed()
Expand All @@ -474,7 +479,7 @@ - (void)completeLoad
if (m_testingCallback)
m_testingCallback(false);

m_state = State::Failed;
m_state = State::Initial;
}

void SystemPreviewController::end()
Expand All @@ -488,7 +493,7 @@ - (void)completeLoad
m_wkSystemPreviewDataTaskDelegate = nullptr;
#endif

m_state = State::Ended;
m_state = State::Initial;
}

void SystemPreviewController::updateProgress(float progress)
Expand Down
4 changes: 1 addition & 3 deletions Source/WebKit/UIProcess/SystemPreviewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ class SystemPreviewController : public CanMakeWeakPtr<SystemPreviewController> {
Initial,
Began,
Loading,
Failed,
Succeeded,
Ended
Viewing
};

State m_state { State::Initial };
Expand Down

0 comments on commit 8c3dd61

Please sign in to comment.