SD is crashing Safari

When I run this script:

tell application "Safari"
   activate
   tell window 1
      make new tab at beginning
   end tell
end tell

Safari crashes and I get this message:

"Safari Died
The application “Safari” appears to have crashed, responding to the following Apple Event:

AppleScript: get source of tab 1 of window id 31387

AEPrint: ‘core’‘getd’{ ‘----’:'obj '{ ‘want’:‘prop’, ‘from’:'obj '{ ‘form’:‘indx’, ‘want’:‘bTab’, ‘seld’:1, ‘from’:'obj '{ ‘form’:'ID ', ‘want’:‘cwin’, ‘seld’:31387, ‘from’:null() } }, ‘form’:‘prop’, ‘seld’:‘conT’ } }"

It seems to be that getting the source of an empty tab crashes SD, in debugging and normal mode.

Script Editor does not crash.

–> Script Debugger 7.0.2 (7A51)
–> Mac OS 10.11.6 (15G1611)

Please see this topic: Safari crash - simple create new document script step -

Hey Ed,

Both of these work perfectly on MacOS 10.12.6 with Safari 11.1 (12605.1.33.1.4).

-Chris

tell application "Safari"
   activate
   tell window 1
      set newTab to make new tab at beginning
   end tell
end tell
tell application "Safari"
   activate
   
   tell window 1
      set newTab to make new tab at beginning
      set current tab to newTab
      set URL of newTab to "https://www.google.com"
   end tell
   
end tell

Hmmm… The first one crashes Safari on most runs.

The second one doesn’t. If I add the “set current tab to newTab” line to the first, following the make new tab line, the first doesn’t crash.

–> Script Debugger 7.0.2 (7A51)
–> Mac OS 10.11.6 (15G1611)
–> Safari 10.1.2

Hey Ed,

Using Script Debugger 7.0.2 (7A51) this works on my system without issue with and without debugging turned on.

repeat 30 times
   tell application "Safari"
      tell window 1
         set newTab to make new tab at beginning
      end tell
   end tell
end repeat

So it looks like there’s some pesky issue between the versions of the OS.

-Chris

It could also be a difference in Safari preferences. For example, what do you have new tab set to open? Since the crash seems to be caused by Safari returning an empty result for an AppleEvent result, that could make a difference.

Mine is set to “Favorites”

True.

Mine is normally set to blank, but I ran some tests with “Favorites” on and didn’t have a problem.

-Chris