Skip to content

Conversation

@Mrazator
Copy link
Member

@Mrazator Mrazator commented Oct 22, 2024

Safari does not always trigger "loadingdone" event (actually it rarely does) and thus in most cases we end up with unloaded fonts on init and paste. It's especially annoying when there are tons of font faces to load, such as with the recent CJK support and half or even less characters remain unloaded.

The solution is loading all the necessary font faces manually in Safari, both on init and when pasting elements.

Fixes #3229

Other improvements

  • Consolidates font faces logic in export under the Fonts class
  • Concurrently loads 10 font faces at a time (loading all 250 font faces at the same time likely isn't a good idea)

TODO

  • Regression test export
  • Double-check font faces are not loaded twice or more times
  • Double-check we don't load font faces which shouldn't be loaded
  • Load only font faces for pasted elements

Follows #8530

@vercel
Copy link

vercel bot commented Oct 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
excalidraw ✅ Ready (Inspect) Visit Preview Oct 23, 2024 6:34pm
excalidraw-package-example ✅ Ready (Inspect) Visit Preview Oct 23, 2024 6:34pm
excalidraw-package-example-with-nextjs ✅ Ready (Inspect) Visit Preview Oct 23, 2024 6:34pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Oct 23, 2024 6:34pm

@Mrazator Mrazator force-pushed the mrazator/load-font-faces-in-safari-manually branch from e950bae to 013d0ec Compare October 22, 2024 20:50
@github-actions
Copy link

github-actions bot commented Oct 22, 2024

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 67.26% (🎯 60%) 66055 / 98197
🟢 Statements 67.26% (🎯 60%) 66055 / 98197
🟢 Functions 64.02% (🎯 63%) 1915 / 2991
🟢 Branches 79.94% (🎯 70%) 7888 / 9867
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/excalidraw/constants.ts 99.55% 66.66% 100% 99.55% 11-12
packages/excalidraw/components/App.tsx 70% 77.61% 71.57% 70% 503-504, 616-625, 725-726, 744-745, 766-826, 829-835, 848-851, 854-930, 933-952, 955-960, 968-978, 980-981, 986-987, 991-993, 1007, 1014-1276, 1336-1337, 1369-1371, 1378-1423, 1449, 1459, 1466-1469, 1478-1482, 1513-1514, 1592-1602, 1607-1622, 1626-1673, 1769-1774, 1803-1808, 1811-1841, 1849-1874, 1887-1978, 1981-1989, 1992-2051, 2054-2095, 2098-2103, 2140-2141, 2164-2165, 2197-2198, 2202-2203, 2223-2231, 2236-2249, 2255-2256, 2260, 2265-2273, 2275-2283, 2295, 2340-2341, 2363-2364, 2371, 2392-2394, 2454-2456, 2459-2464, 2469-2470, 2510-2518, 2523-2532, 2570-2571, 2663-2664, 2668, 2671-2672, 2680-2683, 2692-2705, 2711-2714, 2717, 2719-2720, 2727-2728, 2734-2735, 2738-2739, 2747-2748, 2751-2752, 2763-2771, 2776-2777, 2828-2829, 2843-2849, 2855-2863, 2867-2875, 2879-2880, 2883-2916, 2919-2931, 2942-2943, 2954-2955, 2972-2976, 2980-2983, 2990-2992, 3010-3017, 3020, 3022-3027, 3031-3033, 3079-3080, 3087-3089, 3091-3114, 3131-3163, 3178, 3184, 3241-3244, 3247-3248, 3265-3267, 3289-3290, 3296-3300, 3306-3387, 3441, 3445, 3480-3481, 3540, 3550-3568, 3571-3577, 3580-3581, 3587-3603, 3716-3717, 3740-3754, 3759-3770, 3822-3823, 3895-3905, 3941, 4090-4091, 4093-4100, 4134-4138, 4140-4141, 4143-4146, 4171-4172, 4194-4204, 4214-4216, 4218, 4299-4302, 4324-4332, 4336-4338, 4348-4349, 4351-4371, 4378-4401, 4404-4410, 4427-4430, 4442-4449, 4545-4549, 4553, 4558-4559, 4564-4568, 4601-4602, 4605-4606, 4618-4622, 4627-4628, 4634-4644, 4649-4676, 4681-4692, 4792-4793, 4877, 4902, 4928-4930, 4997-4998, 5016-5017, 5208-5209, 5212-5213, 5221-5222, 5277-5281, 5335-5342, 5348-5418, 5462, 5519, 5546, 5553-5554, 5567-5570, 5601, 5654-5657, 5660-5664, 5666-5673, 5690-5699, 5702-5703, 5833-5834, 5837, 5839-5844, 5850-5852, 5854, 5863, 5885-5890, 5892-5895, 5899-5900, 5910-6006, 6010-6011, 6026-6027, 6063-6069, 6096-6097, 6109-6110, 6138, 6140-6167, 6174-6175, 6197-6198, 6217, 6219-6262, 6267-6268, 6270-6271, 6287-6288, 6294-6295, 6299-6302, 6305-6306, 6320-6346, 6354-6355, 6359-6362, 6364-6368, 6386-6390, 6437-6442, 6444-6446, 6462, 6464-6477, 6502-6505, 6560, 6577-6578, 6580-6603, 6618-6619, 6733-6761, 6816-6817, 6880-6881, 6908-6909, 7003, 7009-7010, 7033-7052, 7067, 7215-7253, 7257-7307, 7322, 7331, 7365-7371, 7398-7400, 7566-7569, 7591-7621, 7634, 7636-7644, 7658, 7660-7668, 7675-7678, 7686-7691, 7723-7724, 7727-7729, 7732-7733, 7756-7757, 7763-7764, 7791-7792, 7875-7876, 7923-7936, 7940-8026, 8103-8106, 8132-8133, 8190, 8213-8219, 8230-8249, 8277-8283, 8315, 8357, 8363, 8378-8385, 8388-8395, 8450, 8528-8529, 8550-8552, 8555, 8569-8593, 8702-8715, 8738-8762, 8771-8810, 8823-8824, 8833-8840, 8858-8865, 8919-8924, 8933-8957, 8959-8960, 9034-9035, 9042, 9044-9080, 9109, 9168, 9207-9209, 9234-9239, 9241-9242, 9247-9249, 9252-9272, 9286-9287, 9293-9302, 9307, 9311-9315, 9324-9328, 9331-9336, 9340-9347, 9377, 9379-9383, 9385-9395, 9411-9413, 9424-9432, 9436-9480, 9483-9554, 9562, 9580-9587, 9589-9611, 9626-9648, 9667-9669, 9715-9716, 9827-9831, 9833-9849, 9851-9855, 9867-9868, 9878-9894, 9913-9932, 9934-9935, 9962-9963, 9967-9968, 9978, 9980-9983, 9985-9986, 10026, 10067-10068, 10078, 10120, 10138-10146, 10157-10173, 10175-10223, 10246-10247, 10279-10282, 10375-10382, 10408-10409, 10454-10525, 10573-10574, 10583-10586, 10591-10592, 10613-10615, 10617-10621, 10659
packages/excalidraw/fonts/Fonts.ts 83.81% 75.75% 86.95% 83.81% 61-67, 73-74, 104-111, 116-138, 155, 173, 183-185, 266, 270-287, 299-304, 307-309, 318-319, 327-331, 474, 481-482, 495
packages/excalidraw/scene/export.ts 88.61% 85.45% 80% 88.61% 49-74, 97, 146-147, 171-175, 320-321, 414-418, 439-448
Generated in workflow #3678 for commit 52b309b by the Vitest Coverage Report Action

@Mrazator Mrazator force-pushed the mrazator/load-font-faces-in-safari-manually branch from 013d0ec to 863e87c Compare October 22, 2024 21:05
@Mrazator Mrazator force-pushed the mrazator/load-font-faces-in-safari-manually branch from 863e87c to db2b63f Compare October 22, 2024 21:07
@Mrazator Mrazator force-pushed the mrazator/load-font-faces-in-safari-manually branch from db2b63f to 9106fb2 Compare October 23, 2024 10:19
@Mrazator Mrazator marked this pull request as ready for review October 23, 2024 11:30
@Mrazator Mrazator requested a review from dwelle October 23, 2024 11:30
@Mrazator Mrazator merged commit 03028ea into master Oct 30, 2024
11 checks passed
@Mrazator Mrazator deleted the mrazator/load-font-faces-in-safari-manually branch October 30, 2024 11:40
Jauhen pushed a commit to Jauhen/excalidraw that referenced this pull request Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fonts are not consistent after reload (Safari mobile, Chrome mobile iOS)

3 participants