Here's the system log that I get when the freezing happens (I copied it from the Console after I restarted the machine):
05/05/16 18:23:55,046 Safari[345]: ERROR: History: Failed to insert item into the history_items table: UNIQUE constraint failed: history_items.url (19)
05/05/16 18:23:55,046 Safari[345]: ERROR: History: Failed to insert item into the history_items table: UNIQUE constraint failed: history_items.url (19)
05/05/16 18:23:59,975 com.apple.WebKit.WebContent[5205]: [18:23:59.975] FigFileForkOpenMainByCFURL signalled err=35 (errno) (open failed) at /Library/Caches/com.apple.xbs/Sources/CoreMedia_frameworks/CoreMedia-1731.15.20 2/Sources/Platform/Darwin/DarwinFile.c line 456
05/05/16 18:23:59,975 com.apple.WebKit.WebContent[5205]: [18:23:59.975] <<<< FigFile >>>> FigFileForkOpenMainByCFURL: opening url "file:///var/folders/76/t9wzpsq17fbc7_4yrvqz0pm40000gn/T//MediaCache/CachedMedi a-4EEz7G", path "/var/folders/76/t9wzpsq17fbc7_4yrvqz0pm40000gn/T//MediaCache/CachedMedia-4EEz7 G" options 0x00000480 failed errno 35 Resource temporarily unavailable
05/05/16 18:24:02,198 com.apple.WebKit.WebContent[5205]: <<<< FigByteStream >>>> FigByteStreamStatsLogOneRead: ByteStream read of 8 bytes @ 18601 took 1.100131 secs. to complete, 1 reads >= 1 sec.
05/05/16 18:24:03,356 com.apple.WebKit.WebContent[5205]: [18:24:03.356] FigAgglomeratorSetObjectForKey signalled err=-16020 (kFigStringConformerError_ParamErr) (NULL key) at /Library/Caches/com.apple.xbs/Sources/CoreMedia/CoreMedia-1731.15.202/Prototype s/LegibleOutput/FigAgglomerator.c line 92
05/05/16 18:24:03,366 com.apple.WebKit.WebContent[5205]: [18:24:03.366] <<<< IQ-CA >>>> piqca_setUsePreQueue: (0x7ff9a128e800) rejecting report of layer being serviced - IQ has not yet begun to update
05/05/16 18:24:03,793 WindowServer[148]: _CGXRemoveWindowFromWindowMovementGroup: window 0x20 is not attached to window 0x2c
05/05/16 18:24:05,457 Safari[345]: tcp_connection_tls_session_error_callback_imp 94 __tcp_connection_tls_session_callback_write_block_invoke.434 error 22
05/05/16 18:24:18,430 Safari[345]: ERROR: History: Failed to insert item into the history_items table: UNIQUE constraint failed: history_items.url (19)
05/05/16 18:24:18,430 Safari[345]: ERROR: History: Failed to insert item into the history_items table: UNIQUE constraint failed: history_items.url (19)
05/05/16 18:24:18,450 Safari[345]: KeychainGetICDPStatus: keychain: -25300
05/05/16 18:24:18,450 Safari[345]: KeychainGetICDPStatus: status: off
05/05/16 18:24:31,959 Safari[345]: tcp_connection_destination_handle_tls_close_notify 89 closing socket due to TLS CLOSE_NOTIFY alert
05/05/16 18:24:31,960 Safari[345]: tcp_connection_tls_session_error_callback_imp 89 __tcp_connection_tls_session_callback_write_block_invoke.434 error 32
05/05/16 18:24:31,960 Safari[345]: tcp_connection_destination_handle_tls_close_notify 90 closing socket due to TLS CLOSE_NOTIFY alert
05/05/16 18:24:31,961 Safari[345]: tcp_connection_tls_session_error_callback_imp 90 __tcp_connection_tls_session_callback_write_block_invoke.434 error 32
05/05/16 18:24:31,962 Safari[345]: tcp_connection_destination_handle_tls_close_notify 93 closing socket due to TLS CLOSE_NOTIFY alert
05/05/16 18:24:31,962 Safari[345]: tcp_connection_tls_session_error_callback_imp 93 __tcp_connection_tls_session_callback_write_block_invoke.434 error 32
05/05/16 18:24:46,401 watchdogd[317]: [watchdog_daemon] @(_wd_daemon_service_thread) - service (com.apple.WindowServer) reported as unresponsive
05/05/16 18:24:47,409 watchdogd[317]: [watchdog_daemon] @(__wd_service_report_unresponsive_block_invoke) - failed to gather a spindump for (com.apple.WindowServer)
05/05/16 18:25:11,470 watchdogd[317]: [watchdog_daemon] @(_wd_daemon_service_thread) - service (com.apple.WindowServer) reported as unresponsive
05/05/16 18:25:12,473 watchdogd[317]: [watchdog_daemon] @(__wd_service_report_unresponsive_block_invoke) - failed to gather a spindump for (com.apple.WindowServer)
05/05/16 18:25:36,000 bootlog[0]: BOOT_TIME 1462465536 0