Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Having many photos in your libary leads to crashing or not responding browser #865

Closed
6 of 9 tasks
newr90 opened this issue Oct 7, 2022 · 30 comments
Closed
6 of 9 tasks

Comments

@newr90
Copy link

newr90 commented Oct 7, 2022

⚠️ This issue respects the following points: ⚠️

Bug description

Having many photos in your libary leads to crashing or not responding browser.

I've got over 10k photos in my cloud. Unfortunately the newest version of maps leads to unexpected behavior of the browser and the app itself. It seems like the last versions of the app try to load all photos instantly, leading to unresponsive browsers and the webserver itself (freezing, not responding).

Last working version which I ve found working for me is 0.1.10 . It keeps reloading photos which come into view.

I've searched for this topic in here. I hope I didn't miss any already open issue.

Steps to reproduce

1.Use latest version of the app
2.Have over 10k of photos (with geo-info) in your cloud
3.Try to load the application
(Safari crashes, Firefox stops responding and takes a lot of time to load the page)

Expected behavior

The old method of preloading the photos should be used. -> Making the app usable for large photo-libaries.

Installation method

Other

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Nginx

Database engine version

MariaDB

Is this bug present after an update or on a fresh install of the server?

No response

Is this bug present after an update or on a fresh install of the app?

Updated from a minor version

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "24.0.6.1",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpauth": 1,
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "default_phone_region": "DE",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "app_install_overwrite": [
            "occweb"
        ],
        "enable_previews": true,
        "enabledPreviewProviders": [
            "OC\\Preview\\Movie",
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\MP4",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\PDF",
            "OC\\Preview\\MOV"
        ],
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "updater.release.channel": "stable",
        "updater.secret": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - accessibility: 1.10.0
  - activity: 2.16.0
  - calendar: 3.5.0
  - circles: 24.0.1
  - cloud_federation_api: 1.7.0
  - comments: 1.14.0
  - contacts: 4.2.2
  - contactsinteraction: 1.5.0
  - dashboard: 7.4.0
  - dav: 1.22.0
  - deck: 1.7.1
  - federatedfilesharing: 1.14.0
  - federation: 1.14.0
  - files: 1.19.0
  - files_external: 1.16.1
  - files_pdfviewer: 2.5.0
  - files_rightclick: 1.3.0
  - files_sharing: 1.16.2
  - files_trashbin: 1.14.0
  - files_versions: 1.17.0
  - files_videoplayer: 1.13.0
  - firstrunwizard: 2.13.0
  - logreader: 2.9.0
  - lookup_server_connector: 1.12.0
  - mail: 1.13.9
  - maps: 0.1.10
  - mediadc: 0.1.9
  - memories: 2.1.3
  - metadata: 0.16.0
  - nextcloud_announcements: 1.13.0
  - notes: 4.5.1
  - notifications: 2.12.1
  - oauth2: 1.12.0
  - occweb: 0.1.0
  - onlyoffice: 7.5.4
  - password_policy: 1.14.0
  - photos: 1.6.0
  - previewgenerator: 5.1.0
  - privacy: 1.8.0
  - provisioning_api: 1.14.0
  - recommendations: 1.3.0
  - richdocumentscode: 22.5.502
  - serverinfo: 1.14.0
  - settings: 1.6.0
  - sharebymail: 1.14.0
  - sharerenamer: 3.1.0
  - support: 1.7.0
  - survey_client: 1.12.0
  - systemtags: 1.14.0
  - tasks: 0.14.4
  - text: 3.5.1
  - theming: 1.15.0
  - twofactor_backupcodes: 1.13.0
  - twofactor_email: 2.7.0
  - twofactor_totp: 6.4.0
  - unsplash: 2.0.1
  - updatenotification: 1.14.0
  - user_status: 1.4.0
  - viewer: 1.8.0
  - weather_status: 1.4.0
  - workflow_ocr: 1.24.5
  - workflowengine: 2.6.0
Disabled:
  - admin_audit
  - encryption
  - recognize: 2.2.1
  - richdocuments: 6.2.0
  - user_ldap

Nextcloud Signing status

No response

Nextcloud Logs

No response

Browser Console

No response

Additional info

No response

@adi2k5
Copy link

adi2k5 commented Oct 14, 2022

Same here, I cannot load photos to maps since some longer time now, if I do it, browser tab completely freezes after few seconds. I'm having 70k+ photos with geotagging in them, with one of the previous versions (probably also 0.1.10 as OP stated), everything was working fine and even 70k+ photos was not a big issue.

@jacotec
Copy link

jacotec commented Oct 19, 2022

Confirmed, maps is currently unusable. Server load is insane, so that I need to disable the app until this is fixed.

@grabnab
Copy link

grabnab commented Oct 21, 2022

I also have issues with the maps app. Earlier versions where much faster.

@khlschrnk
Copy link

khlschrnk commented Oct 26, 2022

I am also affected. Maps is not usable anymore since 0.1.10. I currently got ~35k pictures and the number of pictures has not been sigificantly increased since then.

Additional potential helpful information:
The moment I updated to the v0.2* releases I also updated to php8.1. In the meantime I tried it with php7.4 and the problem still exists.

It is working correctly with ~3k pictures but that does not mean that this is the limit. I just want to say that I got it to run properly with significantly lower amount of pictures.

@Demian98
Copy link

Same here. I have around 30k images (per user) and the map is freezing the browser for a long time. Would live to see this fixed and make maps compatible with large libraries.

@apg1980
Copy link

apg1980 commented Oct 27, 2022

for me as well 70k pictures, wheel is turning long long time, firefox is freezing the tab

@karpiq24
Copy link

Similar issue here, map is opening but it seems it tries to load thousands of photo previews at once, causing server to have a pretty bad time. Some previews load, some don't and the map is very laggy.

@Cebrain
Copy link

Cebrain commented Nov 4, 2022

Can confirm, when opening maps, it is loading all photo previews and is nearly killing the server

@jacotec
Copy link

jacotec commented Nov 4, 2022

@tacruc This is really a showstopper! Maps is pretty embedded in the new "photos" app, but having it enabled with this bug kills the server (and it's unusable for the user as well).

Do you have any idea of a hotfix or workaround (except disabling the maps app)?

@newr90
Copy link
Author

newr90 commented Nov 8, 2022

This app should be removed from the list of featured apps as it's crashing/slowing down servers and browsers. And it seems like no one is interested in making any changes. I know that it's a community project but it could be a serious issue to anyone using this in a productive environment.

@Tirpitz93
Copy link

I have not had a chance to look into the implementation in detail.
would it be possible to filter images loaded by screen bounds (plus margin) and group images serverside based on zoom level.
another thought: Would indexing images by lat & long improve performance in this case, I just noticed my DB did not have an index on these.

@Tirpitz93
Copy link

Something along the lines of:
These snippets largely coppy from similar functions found nearby, I am ny no means a PHP developer so (constructive) criticism is welcome.

PhotosController.php

	public function getPhotosFromDbInArea($lat1, $lng1, $lat2, $lng2): DataResponse {
		$result = $this->geophotoService->getAllFromDBInArea($this->userId, $lat1, $lng1, $lat2, $lng2, True);
		return new DataResponse($result);
	}

GeophotosMapper.php

	public function findAllLocalizedInArea($userId, $lat1, $lng1, $lat2, $lng2, $limit=null, $offset=null) {
		$sql = 'SELECT * FROM `*PREFIX*maps_photos` where `user_id` = ? and `lat` is not null and `lng` is not null and `lat` between ? and ? and `lng` between ? and ?';
		return $this->findEntities($sql, [$userId, $lat1, $lat2, $lng1, $lng2], $limit, $offset);
	}

GeophotoService.php

	public function getAllFromDBInArea($userId, $lat1, $lng1, $lat2, $lng2, bool $respectNomediaAndNoimage=true)
	{
		$lat1 = floatval($lat1);
		$lng1 = floatval($lng1);
		$lat2 = floatval($lat2);
		$lng2 = floatval($lng2);
		$latmin = min($lat1, $lat2);
		$latmax = max($lat1, $lat2);
		$lngmin = min($lng1, $lng2);
		$lngmax = max($lng1, $lng2);
		$ignoredPaths = $respectNomediaAndNoimage ? $this->getIgnoredPaths($userId) : [];
		$photoEntities = $this->photoMapper->findAllLocalizedInArea($userId, $latmin, $lngmin, $latmax, $lngmax);
		$userFolder = $this->getFolderForUser($userId);
		$filesById = [];
		$cache = $userFolder->getStorage()->getCache();
		$previewEnableMimetypes = $this->getPreviewEnabledMimetypes();
		foreach ($photoEntities as $photoEntity) {
			$cacheEntry = $cache->get($photoEntity->getFileId());
			if ($cacheEntry) {
				// this path is relative to owner's storage
				//$path = $cacheEntry->getPath();
				// but we want it relative to current user's storage
				$files = $userFolder->getById($photoEntity->getFileId());
				if (empty($files)) {
					continue;
				}
				$file = array_shift($files);
				if ($file === null) {
					continue;
				}
				$path = $userFolder->getRelativePath( $file->getPath());
				$isIgnored = false;
				foreach ($ignoredPaths as $ignoredPath) {
					if (str_starts_with($path, $ignoredPath)) {
						$isIgnored = true;
						break;
					}
				}
				if (!$isIgnored) {
					$isRoot = $file === $userFolder;

					$file_object = new \stdClass();
					$file_object->fileId = $photoEntity->getFileId();
					$file_object->fileid = $file_object->fileId;
					$file_object->lat = $photoEntity->getLat();
					$file_object->lng = $photoEntity->getLng();
					$file_object->dateTaken = $photoEntity->getDateTaken() ?? \time();
					$file_object->basename = $isRoot ? '' : $file->getName();
					$file_object->filename = $this->normalizePath($path);
					$file_object->etag = $cacheEntry->getEtag();
//Not working for NC21 as Viewer requires String representation of permissions
//                $file_object->permissions = $file->getPermissions();
					$file_object->type = $file->getType();
					$file_object->mime = $file->getMimetype();
					$file_object->lastmod = $file->getMTime();
					$file_object->size = $file->getSize();
					$file_object->path = $path;
					$file_object->hasPreview = in_array($cacheEntry->getMimeType(), $previewEnableMimetypes);
					$filesById[] = $file_object;
				}
			}
		}
		shuffle($filesById);
		return $filesById;
	}

@thiscantbeserious
Copy link

If I have to throw a wild guess there are some background jobs there were never updated since 3 years ago:

https://github.com/nextcloud/maps/tree/master/lib/BackgroundJob

But the dependencies were - so its likely possible that something was forgotten on that regard and the background job is silently not doing anything while it should be actually slowly pregenerating the thumbnails in the background.

@tacruc
Copy link
Collaborator

tacruc commented Jan 2, 2023

v0.2.5-1-nightly has some improves. It's still not perfect but on my Laptop 13k photos load and the app is usable after ca. 20s of loading.
Additonally custom maps allows to load smaller folders so reducing the problem a little.

Notice that v0.2.5-1-nightly is the first nightly version and needs lots of testing for a stable release.

@tacruc
Copy link
Collaborator

tacruc commented Jan 9, 2023

There are further improvements in #924
On my laptop the front end handles 13k pictures reasonably fast.
The back-end is still a bottleneck on the first load.

@newr90
Copy link
Author

newr90 commented Jan 9, 2023

Thank your for working on that problem since NC 25 doesn't support the old version anymore.

@newr90
Copy link
Author

newr90 commented Jan 16, 2023

I was finally able to test the nightly version. Seems to work much better. Doesn't crash the browser anymore. And the server load is much better. Thanks.

@tacruc tacruc closed this as completed Jan 16, 2023
@tacruc
Copy link
Collaborator

tacruc commented Jan 16, 2023

Thanks for testing

@newr90
Copy link
Author

newr90 commented Jan 17, 2023

I am not sure if you re aware of the site not working on mobile devices. In my case the browser is Safari (Iphone). It just doesnt display any content except for the background and nextcloud top bar. It used to work back in older versions, I think.

@tacruc
Copy link
Collaborator

tacruc commented Jan 17, 2023

@newr90 no I'm not aware. Works on my Android device with chrome and Firefox. But it is definitely not optimized for mobile usage (even more overlapping buttons).

@newr90
Copy link
Author

newr90 commented Jan 17, 2023

@tacruc It worked really well i d say. Used it quite often.
Dont know what happened. Maybe i ve got the time to compare the Last working Version vs the nightly version.

@jacotec
Copy link

jacotec commented Jan 18, 2023

@tacruc I've also installed the latest nightly and it's not showing any photo on the map.
In the side bar it shows "My photos: 6k" which sounds reasonable (if it counts only photos with geodata), but not even one single photo appears on the map.

In this map area I'd expect >3k photos:

image

Do you have any idea which might be wrong?

@tacruc
Copy link
Collaborator

tacruc commented Jan 18, 2023

@jacotec can you check the browser console?
Maybe disable the time slider? An scan you zoom out and check if the photos are for example at 0,0?

@jacotec
Copy link

jacotec commented Jan 23, 2023

@tacruc Disabling the slider does not help ... and it adjusts fine in time range after the number of photos are shown in the left side bar.

The console shows some errors:

image

image

image

@tacruc
Copy link
Collaborator

tacruc commented Jan 23, 2023

I think your experience this issue: #947

@khlschrnk
Copy link

I also got the problem that the pictures are not shown in the map with the current version of the app. Disabling Talk does solve this. So #947 seems to be the root cause.

Anyway, speed of maps significantly improved now. I need about a minute for my 41k pictures to load. Thank you for the improvements.

@categulario
Copy link

I just tried out this extension (again) since I saw the release of the 1.0.0 version, and it still crashes my browser (or leaves it so slow I have to close the tab). I don't think it has to do with pictures in my case though. I think it is because I have 1k gpx tracks which doesn't sound like a lot but seems enough to make it not work.

I don't see any errors in the browser's console.

@tacruc
Copy link
Collaborator

tacruc commented Mar 21, 2023

@categulario Do you have all tracks enabled and shown? I have 700 tracks but mostly disabled, and this doesn't crash my browser?
Is there on track that is particularly long?

@categulario
Copy link

I suspect they are all enabled and shown by default and that's causing the slowdown. My tracks average 7k points each (tens of kilometers of cycling)

@tacruc tacruc reopened this Mar 21, 2023
@tacruc tacruc closed this as completed Mar 21, 2023
@categulario
Copy link

and disabling them doesn't seem to be possible because there are 1k of them and the page is already too slow to even start

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests